diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-02-20 18:02:38 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-02-20 18:02:38 +0000 |
commit | 9685d476103ec9491e7c562362d464bff69bbc9a (patch) | |
tree | b4e33d55fa88eb00525f688e7b3ea182462f8c96 /src/regex | |
parent | dd5bdc8f33925604912901f1bde6f4f8652a9585 (diff) | |
download | gnunet-9685d476103ec9491e7c562362d464bff69bbc9a.tar.gz gnunet-9685d476103ec9491e7c562362d464bff69bbc9a.zip |
- start announce immediately (profiler takes care of load balance), reannounce immediately for more avaliability
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/gnunet-daemon-regexprofiler.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/src/regex/gnunet-daemon-regexprofiler.c b/src/regex/gnunet-daemon-regexprofiler.c index 3ca57b4f3..fd6a97d07 100644 --- a/src/regex/gnunet-daemon-regexprofiler.c +++ b/src/regex/gnunet-daemon-regexprofiler.c | |||
@@ -69,11 +69,6 @@ static GNUNET_SCHEDULER_TaskIdentifier reannounce_task; | |||
69 | static struct GNUNET_TIME_Relative reannounce_freq; | 69 | static struct GNUNET_TIME_Relative reannounce_freq; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * Random delay to spread out load on the DHT. | ||
73 | */ | ||
74 | static struct GNUNET_TIME_Relative announce_delay; | ||
75 | |||
76 | /** | ||
77 | * Maximal path compression length for regex announcing. | 72 | * Maximal path compression length for regex announcing. |
78 | */ | 73 | */ |
79 | static unsigned long long max_path_compression; | 74 | static unsigned long long max_path_compression; |
@@ -132,6 +127,7 @@ static void | |||
132 | reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 127 | reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
133 | { | 128 | { |
134 | struct GNUNET_PeerIdentity id; | 129 | struct GNUNET_PeerIdentity id; |
130 | struct GNUNET_TIME_Relative random_delay; | ||
135 | char *regex = cls; | 131 | char *regex = cls; |
136 | 132 | ||
137 | reannounce_task = GNUNET_SCHEDULER_NO_TASK; | 133 | reannounce_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -155,27 +151,24 @@ reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
155 | (unsigned int) max_path_compression, | 151 | (unsigned int) max_path_compression, |
156 | stats_handle); | 152 | stats_handle); |
157 | } | 153 | } |
158 | else | 154 | /* Will result in a double first announce */ |
159 | { | 155 | GNUNET_assert (NULL != announce_handle); |
160 | GNUNET_assert (NULL != announce_handle); | 156 | GNUNET_REGEX_reannounce (announce_handle); |
161 | GNUNET_REGEX_reannounce (announce_handle); | 157 | |
162 | } | 158 | random_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
163 | 159 | GNUNET_CRYPTO_random_u32 ( | |
160 | GNUNET_CRYPTO_QUALITY_WEAK, | ||
161 | 600)); | ||
164 | reannounce_task = | 162 | reannounce_task = |
165 | GNUNET_SCHEDULER_add_delayed ( | 163 | GNUNET_SCHEDULER_add_delayed ( |
166 | GNUNET_TIME_relative_add (reannounce_freq, | 164 | GNUNET_TIME_relative_add (reannounce_freq, random_delay), |
167 | GNUNET_TIME_relative_multiply ( | ||
168 | GNUNET_TIME_UNIT_SECONDS, | ||
169 | GNUNET_CRYPTO_random_u32 ( | ||
170 | GNUNET_CRYPTO_QUALITY_WEAK, | ||
171 | 600))), | ||
172 | &reannounce_regex, | 165 | &reannounce_regex, |
173 | cls); | 166 | cls); |
174 | } | 167 | } |
175 | 168 | ||
176 | 169 | ||
177 | /** | 170 | /** |
178 | * Announce the given regular expression using Mesh and the path compression | 171 | * Announce the given regular expression using regex and the path compression |
179 | * length read from config. | 172 | * length read from config. |
180 | * | 173 | * |
181 | * @param regex regular expression to announce on this peer's mesh. | 174 | * @param regex regular expression to announce on this peer's mesh. |
@@ -193,9 +186,7 @@ announce_regex (const char * regex) | |||
193 | 186 | ||
194 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == reannounce_task); | 187 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == reannounce_task); |
195 | copy = GNUNET_strdup (regex); | 188 | copy = GNUNET_strdup (regex); |
196 | reannounce_task = GNUNET_SCHEDULER_add_delayed (announce_delay, | 189 | reannounce_task = GNUNET_SCHEDULER_add_now (reannounce_regex, (void *) copy); |
197 | reannounce_regex, | ||
198 | (void *) copy); | ||
199 | } | 190 | } |
200 | 191 | ||
201 | 192 | ||
@@ -326,9 +317,6 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
326 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10); | 317 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10); |
327 | 318 | ||
328 | } | 319 | } |
329 | announce_delay = | ||
330 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | ||
331 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 600)); | ||
332 | 320 | ||
333 | stats_handle = GNUNET_STATISTICS_create ("regexprofiler", cfg); | 321 | stats_handle = GNUNET_STATISTICS_create ("regexprofiler", cfg); |
334 | 322 | ||