-fixes mem leaks
authorSree Harsha Totakura <totakura@in.tum.de>
Wed, 25 Jul 2012 09:59:10 +0000 (09:59 +0000)
committerSree Harsha Totakura <totakura@in.tum.de>
Wed, 25 Jul 2012 09:59:10 +0000 (09:59 +0000)
src/testbed/gnunet-service-testbed.c
src/testbed/gnunet-testbed-helper.c
src/testbed/testbed_api.h
src/testbed/testbed_api_hosts.c
src/testbed/valgrind-zlib.supp

index ac0ca26b0f3755aa21d6f3e91ec6aeb9d0303344..f2bb16488cdfff3f9b7148d0b8608d4398cf6e31 100644 (file)
@@ -404,15 +404,6 @@ static GNUNET_SCHEDULER_TaskIdentifier lcf_proc_task_id;
  */
 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
@@ -1543,6 +1534,8 @@ shutdown_task (void *cls,
     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;
   }
 }
 
@@ -1620,7 +1613,6 @@ testbed_run (void *cls,
       {NULL}
     };
 
-  config = GNUNET_CONFIGURATION_dup (cfg);
   GNUNET_SERVER_add_handlers (server,
                               message_handlers);
   GNUNET_SERVER_disconnect_notify (server,
index 737d13c6d0c697a97686006e7143370f911027fe..36eb3e931289429b3a218859d096d59b2004b4e6 100644 (file)
@@ -300,6 +300,7 @@ tokenizer_cb (void *cls, void *client,
   {
     LOG (GNUNET_ERROR_TYPE_WARNING, 
          "Unable to write config file: %s -- exiting\n", config);
+    GNUNET_CONFIGURATION_destroy (cfg);
     GNUNET_free (config);
     goto error;
   }
@@ -312,13 +313,18 @@ tokenizer_cb (void *cls, void *client,
   {
     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);
index 1d984ca933c37bde52b56c6daa16683626ada610..4a5adfa1757ead084f6ea5290d163ab49acc439e 100644 (file)
@@ -56,7 +56,12 @@ enum OperationType
     /**
      * Get peer information operation
      */
-    OP_PEER_INFO
+    OP_PEER_INFO,
+
+    /**
+     * Overlay connection operation
+     */
+    OP_OVERLAY_CONNECT,
   };
 
 
index 066f0a25481be6664d41f393b7598551fe031b10..b4a08336690c4f89cfebb6244931cd5a0ed083fc 100644 (file)
@@ -235,6 +235,7 @@ GNUNET_TESTBED_host_create_with_id (uint32_t id,
                                    uint16_t port)
 {
   struct GNUNET_TESTBED_Host *host;
+  uint32_t new_size;
 
   if ((id < host_list_size) && (NULL != host_list[id]))
   {
@@ -246,13 +247,17 @@ GNUNET_TESTBED_host_create_with_id (uint32_t 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);
@@ -322,18 +327,21 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host)
     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);  
 }
 
 
index 683eb377a0392ecc96d30a3ea96b981847607e30..ca6ce115fcf24a4e50e7e197b3013f9ca39f1d4c 100644 (file)
@@ -2,6 +2,5 @@
    <ZlibInflateReset2UninitJump>
    Memcheck:Cond
    fun:inflateReset2
-   obj:*
-   obj:*
-}
\ No newline at end of file
+   ...
+}