-clearing LCFContext queue on shutdown
authorSree Harsha Totakura <totakura@in.tum.de>
Tue, 3 Jul 2012 13:40:54 +0000 (13:40 +0000)
committerSree Harsha Totakura <totakura@in.tum.de>
Tue, 3 Jul 2012 13:40:54 +0000 (13:40 +0000)
src/testbed/gnunet-service-testbed.c

index cfc70433f40defee07f04bc76090da2ac32a69ef..c42805fff91a1ccb43b697a2e5a2acd4f0361f05 100644 (file)
@@ -893,6 +893,7 @@ static void
 shutdown_task (void *cls,
                const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  struct LCFContextQueue *lcfq;
   uint32_t host_id;
   uint32_t route_id;
 
@@ -907,6 +908,24 @@ shutdown_task (void *cls,
     GNUNET_DISK_file_close (fh);
     fh = NULL;
   }
+  if (NULL != lcfq_head)
+  {
+    if (GNUNET_SCHEDULER_NO_TASK != lcf_proc_task_id)
+    {
+      GNUNET_SCHEDULER_cancel (lcf_proc_task_id);
+      lcf_proc_task_id = GNUNET_SCHEDULER_NO_TASK;
+    }
+    if (NULL != lcfq_head->lcf->rhandle)
+      GNUNET_TESTBED_cancel_registration (lcfq_head->lcf->rhandle);
+  }
+  GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id);
+  for (lcfq = lcfq_head; NULL != lcfq; lcfq = lcfq_head)
+  {
+    GNUNET_CONFIGURATION_destroy (lcfq->lcf->cfg);
+    GNUNET_free (lcfq->lcf);
+    GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq);
+    GNUNET_free (lcfq);
+  }
   /* Clear host list */
   for (host_id = 0; host_id < host_list_size; host_id++)
     if (NULL != host_list[host_id])