Added comments, fixed debug code, added doxygen
authorBart Polot <bart@net.in.tum.de>
Tue, 8 Nov 2011 21:27:30 +0000 (21:27 +0000)
committerBart Polot <bart@net.in.tum.de>
Tue, 8 Nov 2011 21:27:30 +0000 (21:27 +0000)
src/testing/testing.c
src/testing/testing_group.c
src/testing/testing_peergroup.c

index b778b7d036d8ed4cd60cfc75c2949f64802aa2eb..1758886219ef298df930d798a1218fd20705c893 100644 (file)
@@ -106,7 +106,7 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
 #endif
   GNUNET_assert (daemon->phase == SP_GET_HELLO ||
                  daemon->phase == SP_START_DONE);
-  daemon->cb = NULL;
+  daemon->cb = NULL; // FIXME: why??? (see fsm:SP_START_CORE, notify_daemon_started)
   if (daemon->task != GNUNET_SCHEDULER_NO_TASK) /* Assertion here instead? */
     GNUNET_SCHEDULER_cancel (daemon->task);
 
@@ -148,13 +148,12 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
   daemon->phase = SP_START_DONE;
 }
 
-static void
-start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
 
 /**
  * Notify of a peer being up and running.  Scheduled as a task
  * so that variables which may need to be set are set before
  * the connect callback can set up new operations.
+ * FIXME: what variables?????? where from????
  *
  * @param cls the testing daemon
  * @param tc task scheduler context
@@ -189,7 +188,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   int bytes_read;
 
 #if DEBUG_TESTING
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer FSM is in phase %u.\n", d->phase);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %s FSM is in phase %u.\n",
+              GNUNET_i2s (&d->id), d->phase);
 #endif
 
   d->task = GNUNET_SCHEDULER_NO_TASK;
index 171cf1c4840a825674e7dac6a4340ef5bdadf1bd..db763d22a98612f2b4f3882dbbb59e36740c9a9e 100644 (file)
@@ -5543,6 +5543,15 @@ internal_startup_callback (void *cls, const struct GNUNET_PeerIdentity *id,
                                 emsg);
 }
 
+
+/**
+ * Calls GNUNET_TESTING_daemon_continue_startup to set the daemon's state
+ * from HOSTKEY_CREATED to TOPOLOGY_SETUP. Makes sure not to saturate a host
+ * with requests delaying them when needed.
+ * 
+ * @param cls closure: internal context of the daemon.
+ * @param tc TaskContext
+ */
 static void
 internal_continue_startup (void *cls,
                            const struct GNUNET_SCHEDULER_TaskContext *tc)
index a46e1bfb203498cc811e9d5d7a2470632dd19df1..d3290a36c293d52f81a07234b10b5c43cbb7ac2a 100644 (file)
@@ -416,7 +416,7 @@ internal_topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
 #if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Created %d total connections, which is our target number!  Starting next phase of testing.\n",
-                total_connections);
+                pg_start_ctx->total_connections);
 #endif
 
 #if TIMING
@@ -472,7 +472,8 @@ internal_peers_started_callback (void *cls,
 
 #if VERBOSE > 1
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n",
-              (num_peers - peers_left) + 1, num_peers);
+              (pg_start_ctx->total - pg_start_ctx->peers_left) + 1,
+              pg_start_ctx->total);
 #endif
 
   pg_start_ctx->peers_left--;
@@ -481,12 +482,14 @@ internal_peers_started_callback (void *cls,
   {
 #if VERBOSE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "All %d daemons started, now connecting peers!\n", num_peers);
+                "All %d daemons started, now connecting peers!\n",
+                pg_start_ctx->total);
 #endif
     GNUNET_assert (pg_start_ctx->die_task != GNUNET_SCHEDULER_NO_TASK);
     GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task);
 
     pg_start_ctx->expected_connections = UINT_MAX;
+    // FIXME: why whould peers_left be != 0?? Or pg NULL?
     if ((pg_start_ctx->pg != NULL) && (pg_start_ctx->peers_left == 0))
     {
       pg_start_ctx->connect_start_time = GNUNET_TIME_absolute_get ();
@@ -549,17 +552,18 @@ internal_hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id,
 
 #if VERBOSE > 1
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left,
-              num_peers, GNUNET_i2s (id));
+              "Hostkey (%d/%d) created for peer `%s'\n",
+              pg_start_ctx->total - pg_start_ctx->peers_left,
+              pg_start_ctx->total, GNUNET_i2s (id));
 #endif
 
   pg_start_ctx->peers_left--;
   if (GNUNET_YES == update_meter (pg_start_ctx->hostkey_meter))
   {
     GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task);
+    GNUNET_free_non_null (pg_start_ctx->fail_reason);
     /* Set up task in case topology creation doesn't finish
      * within a reasonable amount of time */
-    GNUNET_free_non_null (pg_start_ctx->fail_reason);
     pg_start_ctx->fail_reason = GNUNET_strdup ("from create_topology");
     pg_start_ctx->die_task =
         GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining