- Avoid calling daemons_stop with NULL, minor doxygen fixes
authorBart Polot <bart@net.in.tum.de>
Fri, 24 Feb 2012 16:48:35 +0000 (16:48 +0000)
committerBart Polot <bart@net.in.tum.de>
Fri, 24 Feb 2012 16:48:35 +0000 (16:48 +0000)
src/dht/test_dht_multipeer.c
src/dht/test_dht_twopeer_path_tracking.c

index 48946df757c95e4d27385a7088658e007dec2903..5292a706853e85603f864f19ebd81158369efc0a 100644 (file)
@@ -206,6 +206,11 @@ static enum GNUNET_DHT_RouteOption route_option;
  */
 static GNUNET_SCHEDULER_TaskIdentifier die_task;
 
+/**
+ * Task handle to use to schedule test shutdown
+ */
+GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
+
 /**
  * Global return value (0 for success, anything else for failure)
  */
@@ -224,14 +229,27 @@ shutdown_callback (void *cls, const char *emsg)
     if (ok == 0)
       ok = 2;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Shutdown callback completed.\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown callback completed.\n");
 }
 
 static void
 do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Shutdown requested.\n");
-  GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
+  if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) == 0)
+  {
+    if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
+    {
+      GNUNET_SCHEDULER_cancel(shutdown_task);
+      shutdown_task = GNUNET_SCHEDULER_NO_TASK;
+    }
+  }
+  else
+  {
+    shutdown_task = GNUNET_SCHEDULER_NO_TASK ;
+  }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown requested.\n");
+  if (NULL != pg)
+    GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
   pg = NULL;
 }
 
@@ -790,8 +808,8 @@ run (void *cls, char *const *args, const char *cfgfile,
   pg = GNUNET_TESTING_peergroup_start (cfg, num_peers, TIMEOUT, NULL,
                                        &startup_done, NULL, NULL);
   GNUNET_assert (NULL != pg);
-  GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL,
-                               &do_stop, NULL);
+  shutdown_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL,
+                                               &do_stop, NULL);
 }
 
 
index c30a3f3276e8d1cca7e67b4cde12464a7fe7f67d..6c78a2b2fb3cae8034cab8e1c142f5c66b920ff7 100644 (file)
@@ -86,10 +86,14 @@ static unsigned int total_connections;
  */
 static unsigned int failed_connections;
 
-/* Task handle to use to schedule test failure */
+/**
+ * Task handle to use to schedule test failure
+ */
 GNUNET_SCHEDULER_TaskIdentifier die_task;
 
-/* Global return value (0 for success, anything else for failure) */
+/**
+ * Global return value (0 for success, anything else for failure)
+ */
 static int ok;
 
 /**