connection limits
authorNathan S. Evans <evans@in.tum.de>
Fri, 22 Jul 2011 13:06:59 +0000 (13:06 +0000)
committerNathan S. Evans <evans@in.tum.de>
Fri, 22 Jul 2011 13:06:59 +0000 (13:06 +0000)
src/nse/nse-profiler.c

index a1e15fdcbea7407ec8e6720b0a4395c58b88b3e1..2dbb4cfedcb8b3d99fed48376d9e38bbd996668d 100644 (file)
@@ -31,8 +31,6 @@
 
 #define VERBOSE GNUNET_NO
 
-#define CONNECT_LIMIT GNUNET_YES
-
 struct NSEPeer
 {
   struct NSEPeer *prev;
@@ -93,6 +91,11 @@ static unsigned long long current_round;
  */
 static unsigned long long peers_next_round;
 
+/**
+ * Maximum number of connections to NSE services.
+ */
+static unsigned long long connection_limit;
+
 /**
  * Total number of connections in the whole network.
  */
@@ -229,10 +232,8 @@ connect_nse_service (void *cls,
   GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "TEST_NSE_MULTIPEER: connecting to nse service of peers\n");
   for (i = 0; i < num_peers; i++)
     {
-#if CONNECT_LIMIT
-      if (i % 50 != 0)
+      if ((connection_limit > 0) && (i % (num_peers / connection_limit) != 0))
         continue;
-#endif
       current_peer = GNUNET_malloc(sizeof(struct NSEPeer));
       current_peer->daemon = GNUNET_TESTING_daemon_get(pg, i);
       if (GNUNET_YES == GNUNET_TESTING_daemon_running(GNUNET_TESTING_daemon_get(pg, i)))
@@ -549,6 +550,11 @@ run (void *cls,
       return;
     }
 
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", "connection_limit", &connection_limit))
+    {
+      connection_limit = 0;
+    }
+
   if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, "nse-profiler", "topology_output_file", &topology_file))
     {
       GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Option nse-profiler:topology_output_file is required!\n");