aboutsummaryrefslogtreecommitdiff
path: root/src/regex
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-03-15 15:23:46 +0000
committerBart Polot <bart@net.in.tum.de>2013-03-15 15:23:46 +0000
commit9946234be856427f54494c964d141c79be61772a (patch)
tree46f12c2f7f4272913e7fc2bca1d0421c5e2f991f /src/regex
parentbb6236cd072ab898256ac29f58c84add47c13666 (diff)
downloadgnunet-9946234be856427f54494c964d141c79be61772a.tar.gz
gnunet-9946234be856427f54494c964d141c79be61772a.zip
- change regex daemon to announce every rand(0, t_max) period
Diffstat (limited to 'src/regex')
-rw-r--r--src/regex/gnunet-daemon-regexprofiler.c28
-rw-r--r--src/regex/gnunet-regex-profiler.c11
2 files changed, 19 insertions, 20 deletions
diff --git a/src/regex/gnunet-daemon-regexprofiler.c b/src/regex/gnunet-daemon-regexprofiler.c
index 711f7fa42..afdc4707f 100644
--- a/src/regex/gnunet-daemon-regexprofiler.c
+++ b/src/regex/gnunet-daemon-regexprofiler.c
@@ -64,9 +64,9 @@ static struct GNUNET_REGEX_announce_handle *announce_handle;
64static GNUNET_SCHEDULER_TaskIdentifier reannounce_task; 64static GNUNET_SCHEDULER_TaskIdentifier reannounce_task;
65 65
66/** 66/**
67 * How often reannounce regex. 67 * What's the maximum reannounce period.
68 */ 68 */
69static struct GNUNET_TIME_Relative reannounce_freq; 69static struct GNUNET_TIME_Relative reannounce_period_max;
70 70
71/** 71/**
72 * Maximal path compression length for regex announcing. 72 * Maximal path compression length for regex announcing.
@@ -157,15 +157,13 @@ reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
157 GNUNET_REGEX_reannounce (announce_handle); 157 GNUNET_REGEX_reannounce (announce_handle);
158 } 158 }
159 159
160 random_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 160 random_delay =
161 GNUNET_CRYPTO_random_u32 ( 161 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
162 GNUNET_CRYPTO_QUALITY_WEAK, 162 GNUNET_CRYPTO_random_u32 (
163 600)); 163 GNUNET_CRYPTO_QUALITY_WEAK,
164 reannounce_task = 164 reannounce_period_max.rel_value));
165 GNUNET_SCHEDULER_add_delayed ( 165 reannounce_task = GNUNET_SCHEDULER_add_delayed (random_delay,
166 GNUNET_TIME_relative_add (reannounce_freq, random_delay), 166 &reannounce_regex, cls);
167 &reannounce_regex,
168 cls);
169} 167}
170 168
171 169
@@ -311,13 +309,13 @@ run (void *cls, char *const *args GNUNET_UNUSED,
311 309
312 if (GNUNET_OK != 310 if (GNUNET_OK !=
313 GNUNET_CONFIGURATION_get_value_time (cfg, "REGEXPROFILER", 311 GNUNET_CONFIGURATION_get_value_time (cfg, "REGEXPROFILER",
314 "REANNOUNCE_FREQ", &reannounce_freq)) 312 "REANNOUNCE_PERIOD_MAX",
313 &reannounce_period_max))
315 { 314 {
316 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 315 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
317 "reannounce_freq not given. Using 10 minutes.\n"); 316 "reannounce_period_max not given. Using 10 minutes.\n");
318 reannounce_freq = 317 reannounce_period_max =
319 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10); 318 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10);
320
321 } 319 }
322 320
323 stats_handle = GNUNET_STATISTICS_create ("regexprofiler", cfg); 321 stats_handle = GNUNET_STATISTICS_create ("regexprofiler", cfg);
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c
index 626198de0..600645fa1 100644
--- a/src/regex/gnunet-regex-profiler.c
+++ b/src/regex/gnunet-regex-profiler.c
@@ -37,7 +37,7 @@
37#include "gnunet_testbed_service.h" 37#include "gnunet_testbed_service.h"
38 38
39#define FIND_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 90) 39#define FIND_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 90)
40#define SEARCHES_IN_PARALLEL 2 40#define SEARCHES_IN_PARALLEL 10
41#define ANNOUNCE_DELAY GNUNET_TIME_relative_multiply(\ 41#define ANNOUNCE_DELAY GNUNET_TIME_relative_multiply(\
42 GNUNET_TIME_UNIT_MILLISECONDS,\ 42 GNUNET_TIME_UNIT_MILLISECONDS,\
43 300) 43 300)
@@ -1474,9 +1474,9 @@ policy_filename_cb (void *cls, const char *filename)
1474 1474
1475 peer->policy_file = GNUNET_strdup (filename); 1475 peer->policy_file = GNUNET_strdup (filename);
1476 1476
1477 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Creating peer %i on host %s for policy file %s\n", 1477 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1478 peer->id, 1478 "Creating peer %i on host %s for policy file %s\n",
1479 GNUNET_TESTBED_host_get_hostname (peer->host_handle), 1479 peer->id, GNUNET_TESTBED_host_get_hostname (peer->host_handle),
1480 filename); 1480 filename);
1481 1481
1482 /* Set configuration options specific for this peer 1482 /* Set configuration options specific for this peer
@@ -1484,7 +1484,8 @@ policy_filename_cb (void *cls, const char *filename)
1484 peer->cfg = GNUNET_CONFIGURATION_dup (cfg); 1484 peer->cfg = GNUNET_CONFIGURATION_dup (cfg);
1485 GNUNET_CONFIGURATION_set_value_number (peer->cfg, "REGEXPROFILER", 1485 GNUNET_CONFIGURATION_set_value_number (peer->cfg, "REGEXPROFILER",
1486 "MAX_PATH_COMPRESSION", 1486 "MAX_PATH_COMPRESSION",
1487 (unsigned long long)max_path_compression); 1487 (unsigned long long)
1488 max_path_compression);
1488 GNUNET_CONFIGURATION_set_value_string (peer->cfg, "REGEXPROFILER", 1489 GNUNET_CONFIGURATION_set_value_string (peer->cfg, "REGEXPROFILER",
1489 "POLICY_FILE", filename); 1490 "POLICY_FILE", filename);
1490 1491