exit during errors too
[oweals/gnunet.git] / src / testbed / gnunet-testbed-profiler.c
index 5a674c89da21b9011e113e4fab0f48fb775bf2b2..4168408e94346999c91094b9129e3b8168f1604f 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "platform.h"
 #include "gnunet_common.h"
+#include "gnunet_util_lib.h"
 #include "gnunet_testbed_service.h"
 #include "testbed_api_hosts.h"
 
@@ -357,6 +358,7 @@ peer_churn_cb (void *cls, const char *emsg)
                                                      topology,
                                                      GNUNET_TESTBED_TOPOLOGY_DISABLE_AUTO_RETRY,
                                                      GNUNET_TESTBED_TOPOLOGY_OPTION_END);
+      num_links = num_peers * (num_peers - 1);
       break;
     default:
       GNUNET_assert (0);
@@ -523,7 +525,7 @@ controller_event_cb (void *cls,
     }
     break;
   case STATE_PEERS_LINKING:
-   switch (event->type)
+    switch (event->type)
     {
     case GNUNET_TESTBED_ET_OPERATION_FINISHED:
       /* Control reaches here when a peer linking operation fails */
@@ -538,6 +540,7 @@ controller_event_cb (void *cls,
          print_overlay_links_summary ();         
          GNUNET_SCHEDULER_cancel (abort_task);
          abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL);
+         return;
        }
       }
       break;
@@ -550,19 +553,17 @@ controller_event_cb (void *cls,
        printf (".");
        fflush (stdout);
         established_links++;
-        if ((established_links + failed_links) == 
-            (GNUNET_TESTBED_TOPOLOGY_CLIQUE == topology ? 
-             num_peers * (num_peers -1) : num_links))
-        {
-         print_overlay_links_summary ();
-         result = GNUNET_OK;
-          shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
-        }
       }
       break;
     default:
       GNUNET_assert (0);
     }
+    if ((established_links + failed_links) == num_links)
+    {
+      print_overlay_links_summary ();
+      result = GNUNET_OK;
+      shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
+    }    
     break;
   default:
     GNUNET_assert (0);
@@ -775,7 +776,7 @@ set_topology (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
     *val = GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI;
     return GNUNET_OK;
   }
-  FPRINTF (stderr, _("Only `CLIQUE' and `RANDOM' are permitted"));
+  FPRINTF (stderr, "%s", _("Only `CLIQUE' and `RANDOM' are permitted.\n"));
   return GNUNET_SYSERR;
 }