*/
static GNUNET_SCHEDULER_TaskIdentifier shutdown_task_id;
-/******************/
-/* Testing System */
-/******************/
-
-/**
- * Our configuration; we also use this as template for starting other controllers
- */
-static struct GNUNET_CONFIGURATION_Handle *config;
-
/**
* Function called to notify a client about the connection begin ready to queue
GNUNET_free_non_null (master_context->master_ip);
if (NULL != master_context->system)
GNUNET_TESTING_system_destroy (master_context->system, GNUNET_YES);
+ GNUNET_free (master_context);
+ master_context = NULL;
}
}
{NULL}
};
- config = GNUNET_CONFIGURATION_dup (cfg);
GNUNET_SERVER_add_handlers (server,
message_handlers);
GNUNET_SERVER_disconnect_notify (server,
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"Unable to write config file: %s -- exiting\n", config);
+ GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_free (config);
goto error;
}
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"Error staring gnunet-service-testbed -- exiting\n");
+ GNUNET_CONFIGURATION_destroy (cfg);
goto error;
}
GNUNET_DISK_pipe_close_end (pipe_out, GNUNET_DISK_PIPE_END_WRITE);
GNUNET_DISK_pipe_close_end (pipe_in, GNUNET_DISK_PIPE_END_READ);
done_reading = GNUNET_YES;
config = GNUNET_CONFIGURATION_serialize (cfg, &config_size);
- xconfig_size = GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ cfg = NULL;
+ xconfig_size = GNUNET_TESTBED_compress_config_ (config, config_size,
+ &xconfig);
+ GNUNET_free (config);
wc = GNUNET_malloc (sizeof (struct WriteContext));
wc->length = xconfig_size + sizeof (struct GNUNET_TESTBED_HelperReply);
reply = GNUNET_realloc (xconfig, wc->length);
uint16_t port)
{
struct GNUNET_TESTBED_Host *host;
+ uint32_t new_size;
if ((id < host_list_size) && (NULL != host_list[id]))
{
host->username = username;
host->id = id;
host->port = (0 == port) ? 22 : port;
- if (id >= host_list_size)
+ new_size = host_list_size;
+ while (id >= new_size)
+ new_size += HOST_LIST_GROW_STEP;
+ if (new_size != host_list_size)
{
- host_list_size += HOST_LIST_GROW_STEP;
host_list = GNUNET_realloc (host_list, sizeof (struct GNUNET_TESTBED_Host)
- * host_list_size);
- (void) memset(&host_list[host_list_size - HOST_LIST_GROW_STEP],
- 0, sizeof (struct GNUNET_TESTBED_Host) * host_list_size);
+ * new_size);
+ (void) memset(&host_list[host_list_size], 0,
+ sizeof (struct GNUNET_TESTBED_Host) *
+ (new_size - host_list_size));
+ host_list_size = new_size;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Adding host with id: %u\n", host->id);
GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc);
GNUNET_free (rc);
}
- for (id = 0; id < HOST_LIST_GROW_STEP; id++)
+ GNUNET_free (host);
+ while (host_list_size >= HOST_LIST_GROW_STEP)
{
- if (((host->id + id) >= host_list_size) ||
- (NULL != host_list[host->id + id]))
+ for (id = host_list_size - 1;
+ id > host_list_size - HOST_LIST_GROW_STEP; id--)
+ if (NULL != host_list[id])
+ break;
+ if (id != host_list_size - HOST_LIST_GROW_STEP)
+ break;
+ if (NULL != host_list[id])
break;
- }
- if (HOST_LIST_GROW_STEP == id)
- {
host_list_size -= HOST_LIST_GROW_STEP;
- host_list = GNUNET_realloc (host_list, host_list_size);
}
- GNUNET_free (host);
+ host_list = GNUNET_realloc (host_list, sizeof (struct GNUNET_TESTBED_Host) *
+ host_list_size);
}