aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-07-25 09:59:10 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-07-25 09:59:10 +0000
commit8fcba4447fd83577ec94e5926801c396cf7dbaf8 (patch)
tree8a622ce8313dc0fdc638e17ff30a4e7df34aefab /src/testbed
parent90da8ec92541c5a645ada39ba524198f131ce6e5 (diff)
downloadgnunet-8fcba4447fd83577ec94e5926801c396cf7dbaf8.tar.gz
gnunet-8fcba4447fd83577ec94e5926801c396cf7dbaf8.zip
-fixes mem leaks
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/gnunet-service-testbed.c12
-rw-r--r--src/testbed/gnunet-testbed-helper.c8
-rw-r--r--src/testbed/testbed_api.h7
-rw-r--r--src/testbed/testbed_api_hosts.c34
-rw-r--r--src/testbed/valgrind-zlib.supp5
5 files changed, 38 insertions, 28 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index ac0ca26b0..f2bb16488 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -404,15 +404,6 @@ static GNUNET_SCHEDULER_TaskIdentifier lcf_proc_task_id;
404 */ 404 */
405static GNUNET_SCHEDULER_TaskIdentifier shutdown_task_id; 405static GNUNET_SCHEDULER_TaskIdentifier shutdown_task_id;
406 406
407/******************/
408/* Testing System */
409/******************/
410
411/**
412 * Our configuration; we also use this as template for starting other controllers
413 */
414static struct GNUNET_CONFIGURATION_Handle *config;
415
416 407
417/** 408/**
418 * Function called to notify a client about the connection begin ready to queue 409 * Function called to notify a client about the connection begin ready to queue
@@ -1543,6 +1534,8 @@ shutdown_task (void *cls,
1543 GNUNET_free_non_null (master_context->master_ip); 1534 GNUNET_free_non_null (master_context->master_ip);
1544 if (NULL != master_context->system) 1535 if (NULL != master_context->system)
1545 GNUNET_TESTING_system_destroy (master_context->system, GNUNET_YES); 1536 GNUNET_TESTING_system_destroy (master_context->system, GNUNET_YES);
1537 GNUNET_free (master_context);
1538 master_context = NULL;
1546 } 1539 }
1547} 1540}
1548 1541
@@ -1620,7 +1613,6 @@ testbed_run (void *cls,
1620 {NULL} 1613 {NULL}
1621 }; 1614 };
1622 1615
1623 config = GNUNET_CONFIGURATION_dup (cfg);
1624 GNUNET_SERVER_add_handlers (server, 1616 GNUNET_SERVER_add_handlers (server,
1625 message_handlers); 1617 message_handlers);
1626 GNUNET_SERVER_disconnect_notify (server, 1618 GNUNET_SERVER_disconnect_notify (server,
diff --git a/src/testbed/gnunet-testbed-helper.c b/src/testbed/gnunet-testbed-helper.c
index 737d13c6d..36eb3e931 100644
--- a/src/testbed/gnunet-testbed-helper.c
+++ b/src/testbed/gnunet-testbed-helper.c
@@ -300,6 +300,7 @@ tokenizer_cb (void *cls, void *client,
300 { 300 {
301 LOG (GNUNET_ERROR_TYPE_WARNING, 301 LOG (GNUNET_ERROR_TYPE_WARNING,
302 "Unable to write config file: %s -- exiting\n", config); 302 "Unable to write config file: %s -- exiting\n", config);
303 GNUNET_CONFIGURATION_destroy (cfg);
303 GNUNET_free (config); 304 GNUNET_free (config);
304 goto error; 305 goto error;
305 } 306 }
@@ -312,13 +313,18 @@ tokenizer_cb (void *cls, void *client,
312 { 313 {
313 LOG (GNUNET_ERROR_TYPE_WARNING, 314 LOG (GNUNET_ERROR_TYPE_WARNING,
314 "Error staring gnunet-service-testbed -- exiting\n"); 315 "Error staring gnunet-service-testbed -- exiting\n");
316 GNUNET_CONFIGURATION_destroy (cfg);
315 goto error; 317 goto error;
316 } 318 }
317 GNUNET_DISK_pipe_close_end (pipe_out, GNUNET_DISK_PIPE_END_WRITE); 319 GNUNET_DISK_pipe_close_end (pipe_out, GNUNET_DISK_PIPE_END_WRITE);
318 GNUNET_DISK_pipe_close_end (pipe_in, GNUNET_DISK_PIPE_END_READ); 320 GNUNET_DISK_pipe_close_end (pipe_in, GNUNET_DISK_PIPE_END_READ);
319 done_reading = GNUNET_YES; 321 done_reading = GNUNET_YES;
320 config = GNUNET_CONFIGURATION_serialize (cfg, &config_size); 322 config = GNUNET_CONFIGURATION_serialize (cfg, &config_size);
321 xconfig_size = GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig); 323 GNUNET_CONFIGURATION_destroy (cfg);
324 cfg = NULL;
325 xconfig_size = GNUNET_TESTBED_compress_config_ (config, config_size,
326 &xconfig);
327 GNUNET_free (config);
322 wc = GNUNET_malloc (sizeof (struct WriteContext)); 328 wc = GNUNET_malloc (sizeof (struct WriteContext));
323 wc->length = xconfig_size + sizeof (struct GNUNET_TESTBED_HelperReply); 329 wc->length = xconfig_size + sizeof (struct GNUNET_TESTBED_HelperReply);
324 reply = GNUNET_realloc (xconfig, wc->length); 330 reply = GNUNET_realloc (xconfig, wc->length);
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h
index 1d984ca93..4a5adfa17 100644
--- a/src/testbed/testbed_api.h
+++ b/src/testbed/testbed_api.h
@@ -56,7 +56,12 @@ enum OperationType
56 /** 56 /**
57 * Get peer information operation 57 * Get peer information operation
58 */ 58 */
59 OP_PEER_INFO 59 OP_PEER_INFO,
60
61 /**
62 * Overlay connection operation
63 */
64 OP_OVERLAY_CONNECT,
60 }; 65 };
61 66
62 67
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
index 066f0a254..b4a083366 100644
--- a/src/testbed/testbed_api_hosts.c
+++ b/src/testbed/testbed_api_hosts.c
@@ -235,6 +235,7 @@ GNUNET_TESTBED_host_create_with_id (uint32_t id,
235 uint16_t port) 235 uint16_t port)
236{ 236{
237 struct GNUNET_TESTBED_Host *host; 237 struct GNUNET_TESTBED_Host *host;
238 uint32_t new_size;
238 239
239 if ((id < host_list_size) && (NULL != host_list[id])) 240 if ((id < host_list_size) && (NULL != host_list[id]))
240 { 241 {
@@ -246,13 +247,17 @@ GNUNET_TESTBED_host_create_with_id (uint32_t id,
246 host->username = username; 247 host->username = username;
247 host->id = id; 248 host->id = id;
248 host->port = (0 == port) ? 22 : port; 249 host->port = (0 == port) ? 22 : port;
249 if (id >= host_list_size) 250 new_size = host_list_size;
251 while (id >= new_size)
252 new_size += HOST_LIST_GROW_STEP;
253 if (new_size != host_list_size)
250 { 254 {
251 host_list_size += HOST_LIST_GROW_STEP;
252 host_list = GNUNET_realloc (host_list, sizeof (struct GNUNET_TESTBED_Host) 255 host_list = GNUNET_realloc (host_list, sizeof (struct GNUNET_TESTBED_Host)
253 * host_list_size); 256 * new_size);
254 (void) memset(&host_list[host_list_size - HOST_LIST_GROW_STEP], 257 (void) memset(&host_list[host_list_size], 0,
255 0, sizeof (struct GNUNET_TESTBED_Host) * host_list_size); 258 sizeof (struct GNUNET_TESTBED_Host) *
259 (new_size - host_list_size));
260 host_list_size = new_size;
256 } 261 }
257 LOG (GNUNET_ERROR_TYPE_DEBUG, 262 LOG (GNUNET_ERROR_TYPE_DEBUG,
258 "Adding host with id: %u\n", host->id); 263 "Adding host with id: %u\n", host->id);
@@ -322,18 +327,21 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host)
322 GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc); 327 GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc);
323 GNUNET_free (rc); 328 GNUNET_free (rc);
324 } 329 }
325 for (id = 0; id < HOST_LIST_GROW_STEP; id++) 330 GNUNET_free (host);
331 while (host_list_size >= HOST_LIST_GROW_STEP)
326 { 332 {
327 if (((host->id + id) >= host_list_size) || 333 for (id = host_list_size - 1;
328 (NULL != host_list[host->id + id])) 334 id > host_list_size - HOST_LIST_GROW_STEP; id--)
335 if (NULL != host_list[id])
336 break;
337 if (id != host_list_size - HOST_LIST_GROW_STEP)
338 break;
339 if (NULL != host_list[id])
329 break; 340 break;
330 }
331 if (HOST_LIST_GROW_STEP == id)
332 {
333 host_list_size -= HOST_LIST_GROW_STEP; 341 host_list_size -= HOST_LIST_GROW_STEP;
334 host_list = GNUNET_realloc (host_list, host_list_size);
335 } 342 }
336 GNUNET_free (host); 343 host_list = GNUNET_realloc (host_list, sizeof (struct GNUNET_TESTBED_Host) *
344 host_list_size);
337} 345}
338 346
339 347
diff --git a/src/testbed/valgrind-zlib.supp b/src/testbed/valgrind-zlib.supp
index 683eb377a..ca6ce115f 100644
--- a/src/testbed/valgrind-zlib.supp
+++ b/src/testbed/valgrind-zlib.supp
@@ -2,6 +2,5 @@
2 <ZlibInflateReset2UninitJump> 2 <ZlibInflateReset2UninitJump>
3 Memcheck:Cond 3 Memcheck:Cond
4 fun:inflateReset2 4 fun:inflateReset2
5 obj:* 5 ...
6 obj:* 6}
7} \ No newline at end of file