- fix handling of duplicate incoming channel create with respect to queued retransmis...
[oweals/gnunet.git] / src / mesh / gnunet-mesh-profiler.c
index dbbff157b1f054d84b0ff2096090230ead0f9d22..5c07fba4b75cc16249774cf76b858bbf9e043884 100644 (file)
@@ -226,17 +226,35 @@ static GNUNET_SCHEDULER_TaskIdentifier test_task;
  */
 static unsigned int current_round;
 
-
 /**
  * Do preconnect? (Each peer creates a tunnel to one other peer).
  */
 static int do_warmup;
 
+/**
+ * Warmup progress.
+ */
+static unsigned int peers_warmup;
+
 /**
  * Flag to notify callbacks not to generate any new traffic anymore.
  */
 static int test_finished;
 
+
+/**
+ * START THE TEST ITSELF, AS WE ARE CONNECTED TO THE MESH SERVICES.
+ *
+ * Testcase continues when the root receives confirmation of connected peers,
+ * on callback funtion ch.
+ *
+ * @param cls Closure (unsued).
+ * @param tc Task Context.
+ */
+static void
+start_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+
+
 /**
  * Calculate a random delay.
  *
@@ -774,8 +792,13 @@ incoming_channel (void *cls, struct GNUNET_MESH_Channel *channel,
   GNUNET_assert (NULL != peer);
   if (NULL == peers[n].incoming)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "WARMUP %u <= %u\n",
-                n, get_index (peer), channel);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "WARMUP %3u: %u <= %u\n",
+                peers_warmup, n, get_index (peer));
+    peers_warmup++;
+    if (peers_warmup < peers_total)
+      return NULL;
+    test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                              &start_test, NULL);
     return NULL;
   }
   GNUNET_assert (peer == peers[n].incoming);
@@ -923,7 +946,6 @@ peer_id_cb (void *cls,
        const char *emsg)
 {
   long n = (long) cls;
-  struct GNUNET_TIME_Relative delay;
 
   if (NULL == pinfo || NULL != emsg)
   {
@@ -946,10 +968,12 @@ peer_id_cb (void *cls,
     return;
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got all IDs, starting profiler\n");
   if (do_warmup)
+  {
     warmup();
-  delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
-                                         150 * peers_total);
-  test_task = GNUNET_SCHEDULER_add_delayed (delay, &start_test, NULL);
+    return; /* start_test from incoming_channel */
+  }
+  test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                            &start_test, NULL);
 }
 
 /**
@@ -1036,7 +1060,7 @@ main (int argc, char *argv[])
     return 1;
   }
 
-  do_warmup = (5 > argc || argv[4][0] == 'N');
+  do_warmup = (5 > argc || argv[4][0] != 'N');
 
   ids = GNUNET_CONTAINER_multipeermap_create (2 * peers_total, GNUNET_YES);
   GNUNET_assert (NULL != ids);