aboutsummaryrefslogtreecommitdiff
path: root/src/regex/gnunet-daemon-regexprofiler.c
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/gnunet-daemon-regexprofiler.c
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/gnunet-daemon-regexprofiler.c')
-rw-r--r--src/regex/gnunet-daemon-regexprofiler.c28
1 files changed, 13 insertions, 15 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);