diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-04-29 23:16:05 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-04-29 23:16:05 +0200 |
commit | c89e2dcd8976e45c85aef5cc77e2b96baffd4980 (patch) | |
tree | ebe78286687661ce3ab1d888df3f377f68e18efe /src/zonemaster | |
parent | ce2864cfaa27e55096b480bf35db5f8cee2a5e7e (diff) | |
download | gnunet-c89e2dcd8976e45c85aef5cc77e2b96baffd4980.tar.gz gnunet-c89e2dcd8976e45c85aef5cc77e2b96baffd4980.zip |
batch NAMESTORE operation also in zonemaster
Diffstat (limited to 'src/zonemaster')
-rw-r--r-- | src/zonemaster/gnunet-service-zonemaster.c | 393 |
1 files changed, 254 insertions, 139 deletions
diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c index 25baf4396..5c3356784 100644 --- a/src/zonemaster/gnunet-service-zonemaster.c +++ b/src/zonemaster/gnunet-service-zonemaster.c | |||
@@ -36,6 +36,18 @@ | |||
36 | #define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename) | 36 | #define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename) |
37 | 37 | ||
38 | 38 | ||
39 | /** | ||
40 | * How often do we measure the delta between desired zone | ||
41 | * iteration speed and actual speed, and tell statistics | ||
42 | * service about it? | ||
43 | */ | ||
44 | #define DELTA_INTERVAL 100 | ||
45 | |||
46 | /** | ||
47 | * How many records do we fetch | ||
48 | * in one shot from the namestore? | ||
49 | */ | ||
50 | #define NS_BLOCK_SIZE 100 | ||
39 | 51 | ||
40 | /** | 52 | /** |
41 | * The initial interval in milliseconds btween puts in | 53 | * The initial interval in milliseconds btween puts in |
@@ -79,17 +91,17 @@ | |||
79 | /** | 91 | /** |
80 | * Handle for DHT PUT activity triggered from the namestore monitor. | 92 | * Handle for DHT PUT activity triggered from the namestore monitor. |
81 | */ | 93 | */ |
82 | struct MonitorActivity | 94 | struct DhtPutActivity |
83 | { | 95 | { |
84 | /** | 96 | /** |
85 | * Kept in a DLL. | 97 | * Kept in a DLL. |
86 | */ | 98 | */ |
87 | struct MonitorActivity *next; | 99 | struct DhtPutActivity *next; |
88 | 100 | ||
89 | /** | 101 | /** |
90 | * Kept in a DLL. | 102 | * Kept in a DLL. |
91 | */ | 103 | */ |
92 | struct MonitorActivity *prev; | 104 | struct DhtPutActivity *prev; |
93 | 105 | ||
94 | /** | 106 | /** |
95 | * Handle for the DHT PUT operation. | 107 | * Handle for the DHT PUT operation. |
@@ -131,12 +143,22 @@ static struct GNUNET_NAMESTORE_ZoneMonitor *zmon; | |||
131 | /** | 143 | /** |
132 | * Head of monitor activities; kept in a DLL. | 144 | * Head of monitor activities; kept in a DLL. |
133 | */ | 145 | */ |
134 | static struct MonitorActivity *ma_head; | 146 | static struct DhtPutActivity *ma_head; |
135 | 147 | ||
136 | /** | 148 | /** |
137 | * Tail of monitor activities; kept in a DLL. | 149 | * Tail of monitor activities; kept in a DLL. |
138 | */ | 150 | */ |
139 | static struct MonitorActivity *ma_tail; | 151 | static struct DhtPutActivity *ma_tail; |
152 | |||
153 | /** | ||
154 | * Head of iteration put activities; kept in a DLL. | ||
155 | */ | ||
156 | static struct DhtPutActivity *it_head; | ||
157 | |||
158 | /** | ||
159 | * Tail of iteration put activities; kept in a DLL. | ||
160 | */ | ||
161 | static struct DhtPutActivity *it_tail; | ||
140 | 162 | ||
141 | /** | 163 | /** |
142 | * Useful for zone update for DHT put | 164 | * Useful for zone update for DHT put |
@@ -149,6 +171,21 @@ static unsigned long long num_public_records; | |||
149 | static unsigned long long last_num_public_records; | 171 | static unsigned long long last_num_public_records; |
150 | 172 | ||
151 | /** | 173 | /** |
174 | * Number of successful put operations performed in the current | ||
175 | * measurement cycle (as measured in #check_zone_dht_next()). | ||
176 | */ | ||
177 | static unsigned long long put_cnt; | ||
178 | |||
179 | /** | ||
180 | * What is the frequency at which we currently would like | ||
181 | * to perform DHT puts (per record)? Calculated in | ||
182 | * update_velocity() from the #zone_publish_time_window() | ||
183 | * and the total number of record sets we have (so far) | ||
184 | * observed in the zone. | ||
185 | */ | ||
186 | static struct GNUNET_TIME_Relative next_put_interval; | ||
187 | |||
188 | /** | ||
152 | * Minimum relative expiration time of records seem during the current | 189 | * Minimum relative expiration time of records seem during the current |
153 | * zone iteration. | 190 | * zone iteration. |
154 | */ | 191 | */ |
@@ -171,11 +208,31 @@ static struct GNUNET_TIME_Relative zone_publish_time_window_default; | |||
171 | static struct GNUNET_TIME_Relative zone_publish_time_window; | 208 | static struct GNUNET_TIME_Relative zone_publish_time_window; |
172 | 209 | ||
173 | /** | 210 | /** |
211 | * When did we last start measuring the #DELTA_INTERVAL successful | ||
212 | * DHT puts? Used for velocity calculations. | ||
213 | */ | ||
214 | static struct GNUNET_TIME_Absolute last_put_100; | ||
215 | |||
216 | /** | ||
217 | * By how much should we try to increase our per-record iteration speed | ||
218 | * (over the desired speed calculated directly from the #put_interval)? | ||
219 | * Basically this value corresponds to the per-record CPU time overhead | ||
220 | * we have. | ||
221 | */ | ||
222 | static struct GNUNET_TIME_Relative sub_delta; | ||
223 | |||
224 | /** | ||
174 | * zone publish task | 225 | * zone publish task |
175 | */ | 226 | */ |
176 | static struct GNUNET_SCHEDULER_Task *zone_publish_task; | 227 | static struct GNUNET_SCHEDULER_Task *zone_publish_task; |
177 | 228 | ||
178 | /** | 229 | /** |
230 | * How many more values are left for the current query before we need | ||
231 | * to explicitly ask the namestore for more? | ||
232 | */ | ||
233 | static unsigned int ns_iteration_left; | ||
234 | |||
235 | /** | ||
179 | * #GNUNET_YES if zone has never been published before | 236 | * #GNUNET_YES if zone has never been published before |
180 | */ | 237 | */ |
181 | static int first_zone_iteration; | 238 | static int first_zone_iteration; |
@@ -196,7 +253,7 @@ static int cache_keys; | |||
196 | static void | 253 | static void |
197 | shutdown_task (void *cls) | 254 | shutdown_task (void *cls) |
198 | { | 255 | { |
199 | struct MonitorActivity *ma; | 256 | struct DhtPutActivity *ma; |
200 | 257 | ||
201 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 258 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
202 | "Shutting down!\n"); | 259 | "Shutting down!\n"); |
@@ -257,8 +314,10 @@ publish_zone_dht_next (void *cls) | |||
257 | { | 314 | { |
258 | zone_publish_task = NULL; | 315 | zone_publish_task = NULL; |
259 | GNUNET_assert (NULL != namestore_iter); | 316 | GNUNET_assert (NULL != namestore_iter); |
317 | GNUNET_assert (0 == ns_iteration_left); | ||
318 | ns_iteration_left = NS_BLOCK_SIZE; | ||
260 | GNUNET_NAMESTORE_zone_iterator_next (namestore_iter, | 319 | GNUNET_NAMESTORE_zone_iterator_next (namestore_iter, |
261 | 1); | 320 | NS_BLOCK_SIZE); |
262 | } | 321 | } |
263 | 322 | ||
264 | 323 | ||
@@ -272,144 +331,188 @@ publish_zone_dht_start (void *cls); | |||
272 | 331 | ||
273 | 332 | ||
274 | /** | 333 | /** |
275 | * How often do we measure the delta between desired zone | 334 | * Continuation called from DHT once the PUT operation triggered |
276 | * iteration speed and actual speed, and tell statistics | 335 | * by a monitor is done. |
277 | * service about it? | 336 | * |
337 | * @param cls a `struct DhtPutActivity` | ||
338 | * @param success #GNUNET_OK on success | ||
278 | */ | 339 | */ |
279 | #define DELTA_INTERVAL 100 | 340 | static void |
341 | dht_put_monitor_continuation (void *cls, | ||
342 | int success) | ||
343 | { | ||
344 | struct DhtPutActivity *ma = cls; | ||
345 | |||
346 | num_public_records++; | ||
347 | GNUNET_CONTAINER_DLL_remove (ma_head, | ||
348 | ma_tail, | ||
349 | ma); | ||
350 | GNUNET_free (ma); | ||
351 | } | ||
280 | 352 | ||
281 | 353 | ||
282 | /** | 354 | /** |
283 | * Continuation called from DHT once the PUT operation is done. | 355 | * Check if the current zone iteration needs to be continued |
284 | * | 356 | * by calling #publish_zone_dht_next(), and if so with what delay. |
285 | * @param cls closure, NULL if called from regular iteration, | ||
286 | * `struct MonitorActivity` if called from #handle_monitor_event. | ||
287 | * @param success #GNUNET_OK on success | ||
288 | */ | 357 | */ |
289 | static void | 358 | static void |
290 | dht_put_continuation (void *cls, | 359 | check_zone_dht_next () |
291 | int success) | ||
292 | { | 360 | { |
293 | struct MonitorActivity *ma = cls; | ||
294 | static unsigned long long put_cnt; | ||
295 | static struct GNUNET_TIME_Absolute last_put_100; | ||
296 | static struct GNUNET_TIME_Relative sub_delta; | ||
297 | struct GNUNET_TIME_Relative next_put_interval; | ||
298 | struct GNUNET_TIME_Relative delay; | 361 | struct GNUNET_TIME_Relative delay; |
299 | 362 | ||
300 | num_public_records++; | 363 | if (0 != ns_iteration_left) |
301 | if (NULL == ma) | 364 | return; /* current NAMESTORE iteration not yet done */ |
365 | if (NULL != it_head) | ||
366 | return; /* waiting on DHT */ | ||
367 | delay = GNUNET_TIME_relative_subtract (next_put_interval, | ||
368 | sub_delta); | ||
369 | /* We delay *once* per #NS_BLOCK_SIZE, so we need to multiply the | ||
370 | per-record delay calculated so far with the #NS_BLOCK_SIZE */ | ||
371 | delay = GNUNET_TIME_relative_multiply (delay, | ||
372 | NS_BLOCK_SIZE); | ||
373 | GNUNET_assert (NULL == zone_publish_task); | ||
374 | zone_publish_task = GNUNET_SCHEDULER_add_delayed (delay, | ||
375 | &publish_zone_dht_next, | ||
376 | NULL); | ||
377 | } | ||
378 | |||
379 | |||
380 | /** | ||
381 | * Re-calculate our velocity and the desired velocity. | ||
382 | * We have succeeded in making #DELTA_INTERVAL puts, so | ||
383 | * now calculate the new desired delay between puts. | ||
384 | */ | ||
385 | static void | ||
386 | update_velocity () | ||
387 | { | ||
388 | struct GNUNET_TIME_Relative delta; | ||
389 | unsigned long long pct = 0; | ||
390 | |||
391 | /* How fast were we really? */ | ||
392 | delta = GNUNET_TIME_absolute_get_duration (last_put_100); | ||
393 | delta.rel_value_us /= DELTA_INTERVAL; | ||
394 | last_put_100 = GNUNET_TIME_absolute_get (); | ||
395 | |||
396 | /* calculate expected frequency */ | ||
397 | if ( (num_public_records > last_num_public_records) && | ||
398 | (GNUNET_NO == first_zone_iteration) ) | ||
302 | { | 399 | { |
303 | active_put = NULL; | 400 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
304 | if ( (num_public_records > last_num_public_records) && | 401 | "Last record count was lower than current record count. Reducing interval.\n"); |
305 | (GNUNET_NO == first_zone_iteration) ) | 402 | put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window, |
403 | num_public_records); | ||
404 | next_put_interval = GNUNET_TIME_relative_divide (put_interval, | ||
405 | LATE_ITERATION_SPEEDUP_FACTOR); | ||
406 | } | ||
407 | else | ||
408 | { | ||
409 | next_put_interval = put_interval; | ||
410 | } | ||
411 | |||
412 | next_put_interval = GNUNET_TIME_relative_min (next_put_interval, | ||
413 | MAXIMUM_ZONE_ITERATION_INTERVAL); | ||
414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
415 | "Desired global zone iteration interval is %s/record!\n", | ||
416 | GNUNET_STRINGS_relative_time_to_string (next_put_interval, | ||
417 | GNUNET_YES)); | ||
418 | |||
419 | /* Tell statistics actual vs. desired speed */ | ||
420 | GNUNET_STATISTICS_set (statistics, | ||
421 | "Target zone iteration velocity (μs)", | ||
422 | next_put_interval.rel_value_us, | ||
423 | GNUNET_NO); | ||
424 | GNUNET_STATISTICS_set (statistics, | ||
425 | "Current zone iteration velocity (μs)", | ||
426 | delta.rel_value_us, | ||
427 | GNUNET_NO); | ||
428 | /* update "sub_delta" based on difference, taking | ||
429 | previous sub_delta into account! */ | ||
430 | if (next_put_interval.rel_value_us > delta.rel_value_us) | ||
431 | { | ||
432 | /* We were too fast, reduce sub_delta! */ | ||
433 | struct GNUNET_TIME_Relative corr; | ||
434 | |||
435 | corr = GNUNET_TIME_relative_subtract (next_put_interval, | ||
436 | delta); | ||
437 | if (sub_delta.rel_value_us > delta.rel_value_us) | ||
306 | { | 438 | { |
307 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 439 | /* Reduce sub_delta by corr */ |
308 | "Last record count was lower than current record count. Reducing interval.\n"); | 440 | sub_delta = GNUNET_TIME_relative_subtract (sub_delta, |
309 | put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window, | 441 | corr); |
310 | num_public_records); | ||
311 | next_put_interval = GNUNET_TIME_relative_divide (put_interval, | ||
312 | LATE_ITERATION_SPEEDUP_FACTOR); | ||
313 | } | 442 | } |
314 | else | 443 | else |
315 | { | 444 | { |
316 | next_put_interval = put_interval; | 445 | /* We're doing fine with waiting the full time, this |
446 | should theoretically only happen if we run at | ||
447 | infinite speed. */ | ||
448 | sub_delta = GNUNET_TIME_UNIT_ZERO; | ||
317 | } | 449 | } |
318 | next_put_interval = GNUNET_TIME_relative_min (next_put_interval, | 450 | } |
319 | MAXIMUM_ZONE_ITERATION_INTERVAL); | 451 | else if (next_put_interval.rel_value_us < delta.rel_value_us) |
320 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 452 | { |
321 | "PUT complete, next PUT in %s!\n", | 453 | /* We were too slow, increase sub_delta! */ |
322 | GNUNET_STRINGS_relative_time_to_string (next_put_interval, | 454 | struct GNUNET_TIME_Relative corr; |
323 | GNUNET_YES)); | 455 | |
324 | /* compute velocities and delay corrections to apply */ | 456 | corr = GNUNET_TIME_relative_subtract (delta, |
325 | if (0 == put_cnt) | 457 | next_put_interval); |
326 | last_put_100 = GNUNET_TIME_absolute_get (); /* first time! */ | 458 | sub_delta = GNUNET_TIME_relative_add (sub_delta, |
327 | put_cnt++; | 459 | corr); |
328 | if (0 == put_cnt % DELTA_INTERVAL) | 460 | if (sub_delta.rel_value_us > next_put_interval.rel_value_us) |
329 | { | 461 | { |
330 | struct GNUNET_TIME_Relative delta; | 462 | /* CPU overload detected, we cannot go at desired speed, |
331 | unsigned long long pct = 0; | 463 | as this would mean using a negative delay. */ |
332 | 464 | /* compute how much faster we would want to be for | |
333 | /* How fast were we really? */ | 465 | the desired velocity */ |
334 | delta = GNUNET_TIME_absolute_get_duration (last_put_100); | 466 | if (0 == next_put_interval.rel_value_us) |
335 | delta.rel_value_us /= DELTA_INTERVAL; | 467 | pct = UINT64_MAX; /* desired speed is infinity ... */ |
336 | last_put_100 = GNUNET_TIME_absolute_get (); | 468 | else |
337 | /* Tell statistics actual vs. desired speed */ | 469 | pct = (sub_delta.rel_value_us - next_put_interval.rel_value_us) * 100LLU |
338 | GNUNET_STATISTICS_set (statistics, | 470 | / next_put_interval.rel_value_us; |
339 | "Target zone iteration velocity (μs)", | 471 | sub_delta = next_put_interval; |
340 | next_put_interval.rel_value_us, | 472 | } |
341 | GNUNET_NO); | ||
342 | GNUNET_STATISTICS_set (statistics, | ||
343 | "Current zone iteration velocity (μs)", | ||
344 | delta.rel_value_us, | ||
345 | GNUNET_NO); | ||
346 | /* update "sub_delta" based on difference, taking | ||
347 | previous sub_delta into account! */ | ||
348 | if (next_put_interval.rel_value_us > delta.rel_value_us) | ||
349 | { | ||
350 | /* We were too fast, reduce sub_delta! */ | ||
351 | struct GNUNET_TIME_Relative corr; | ||
352 | |||
353 | corr = GNUNET_TIME_relative_subtract (next_put_interval, | ||
354 | delta); | ||
355 | if (sub_delta.rel_value_us > delta.rel_value_us) | ||
356 | { | ||
357 | /* Reduce sub_delta by corr */ | ||
358 | sub_delta = GNUNET_TIME_relative_subtract (sub_delta, | ||
359 | corr); | ||
360 | } | ||
361 | else | ||
362 | { | ||
363 | /* We're doing fine with waiting the full time, this | ||
364 | should theoretically only happen if we run at | ||
365 | infinite speed. */ | ||
366 | sub_delta = GNUNET_TIME_UNIT_ZERO; | ||
367 | } | ||
368 | } | ||
369 | else if (next_put_interval.rel_value_us < delta.rel_value_us) | ||
370 | { | ||
371 | /* We were too slow, increase sub_delta! */ | ||
372 | struct GNUNET_TIME_Relative corr; | ||
373 | |||
374 | corr = GNUNET_TIME_relative_subtract (delta, | ||
375 | next_put_interval); | ||
376 | sub_delta = GNUNET_TIME_relative_add (sub_delta, | ||
377 | corr); | ||
378 | if (sub_delta.rel_value_us > next_put_interval.rel_value_us) | ||
379 | { | ||
380 | /* CPU overload detected, we cannot go at desired speed, | ||
381 | as this would mean using a negative delay. */ | ||
382 | sub_delta = next_put_interval; | ||
383 | /* compute how much faster we would want to be for | ||
384 | the desired velocity */ | ||
385 | if (0 == next_put_interval.rel_value_us) | ||
386 | pct = UINT64_MAX; /* desired speed is infinity ... */ | ||
387 | else | ||
388 | pct = sub_delta.rel_value_us * 100 / next_put_interval.rel_value_us; | ||
389 | } | ||
390 | } | ||
391 | GNUNET_STATISTICS_set (statistics, | ||
392 | "% speed increase needed for target velocity", | ||
393 | pct, | ||
394 | GNUNET_NO); | ||
395 | } /* end of periodic velocity calculations */ | ||
396 | delay = GNUNET_TIME_relative_subtract (next_put_interval, | ||
397 | sub_delta); | ||
398 | GNUNET_assert (NULL == zone_publish_task); | ||
399 | zone_publish_task = GNUNET_SCHEDULER_add_delayed (delay, | ||
400 | &publish_zone_dht_next, | ||
401 | NULL); | ||
402 | } | 473 | } |
403 | else | 474 | GNUNET_STATISTICS_set (statistics, |
475 | "% speed increase needed for target velocity", | ||
476 | pct, | ||
477 | GNUNET_NO); | ||
478 | GNUNET_STATISTICS_set (statistics, | ||
479 | "# records processed in current iteration", | ||
480 | num_public_records, | ||
481 | GNUNET_NO); | ||
482 | } | ||
483 | |||
484 | |||
485 | /** | ||
486 | * Continuation called from DHT once the PUT operation is done. | ||
487 | * | ||
488 | * @param cls a `struct DhtPutActivity` | ||
489 | * @param success #GNUNET_OK on success | ||
490 | */ | ||
491 | static void | ||
492 | dht_put_continuation (void *cls, | ||
493 | int success) | ||
494 | { | ||
495 | struct DhtPutActivity *ma = cls; | ||
496 | |||
497 | num_public_records++; | ||
498 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
499 | "PUT complete (%s)\n", | ||
500 | (GNUNET_OK == success) ? "success" : "failure"); | ||
501 | GNUNET_CONTAINER_DLL_remove (it_head, | ||
502 | it_tail, | ||
503 | ma); | ||
504 | GNUNET_free (ma); | ||
505 | if (GNUNET_OK == success) | ||
404 | { | 506 | { |
405 | GNUNET_CONTAINER_DLL_remove (ma_head, | 507 | put_cnt++; |
406 | ma_tail, | 508 | if (0 == put_cnt % DELTA_INTERVAL) |
407 | ma); | 509 | update_velocity (); |
408 | GNUNET_free (ma); | ||
409 | } | 510 | } |
511 | check_zone_dht_next (); | ||
410 | } | 512 | } |
411 | 513 | ||
412 | 514 | ||
515 | |||
413 | /** | 516 | /** |
414 | * Convert namestore records from the internal format to that | 517 | * Convert namestore records from the internal format to that |
415 | * suitable for publication (removes private records, converts | 518 | * suitable for publication (removes private records, converts |
@@ -460,7 +563,8 @@ convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd, | |||
460 | * @param label label to store under | 563 | * @param label label to store under |
461 | * @param rd_public public record data | 564 | * @param rd_public public record data |
462 | * @param rd_public_count number of records in @a rd_public | 565 | * @param rd_public_count number of records in @a rd_public |
463 | * @param pc_arg closure argument to pass to the #dht_put_continuation | 566 | * @param cont function to call with PUT result |
567 | * @param cont_cls closure for @a cont | ||
464 | * @return DHT PUT handle, NULL on error | 568 | * @return DHT PUT handle, NULL on error |
465 | */ | 569 | */ |
466 | static struct GNUNET_DHT_PutHandle * | 570 | static struct GNUNET_DHT_PutHandle * |
@@ -468,7 +572,8 @@ perform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
468 | const char *label, | 572 | const char *label, |
469 | const struct GNUNET_GNSRECORD_Data *rd_public, | 573 | const struct GNUNET_GNSRECORD_Data *rd_public, |
470 | unsigned int rd_public_count, | 574 | unsigned int rd_public_count, |
471 | void *pc_arg) | 575 | GNUNET_DHT_PutContinuation cont, |
576 | void *cont_cls) | ||
472 | { | 577 | { |
473 | struct GNUNET_GNSRECORD_Block *block; | 578 | struct GNUNET_GNSRECORD_Block *block; |
474 | struct GNUNET_HashCode query; | 579 | struct GNUNET_HashCode query; |
@@ -519,8 +624,8 @@ perform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
519 | block_size, | 624 | block_size, |
520 | block, | 625 | block, |
521 | expire, | 626 | expire, |
522 | &dht_put_continuation, | 627 | cont, |
523 | pc_arg); | 628 | cont_cls); |
524 | GNUNET_free (block); | 629 | GNUNET_free (block); |
525 | return ret; | 630 | return ret; |
526 | } | 631 | } |
@@ -642,8 +747,10 @@ put_gns_record (void *cls, | |||
642 | { | 747 | { |
643 | struct GNUNET_GNSRECORD_Data rd_public[rd_count]; | 748 | struct GNUNET_GNSRECORD_Data rd_public[rd_count]; |
644 | unsigned int rd_public_count; | 749 | unsigned int rd_public_count; |
750 | struct DhtPutActivity *ma; | ||
645 | 751 | ||
646 | (void) cls; | 752 | (void) cls; |
753 | ns_iteration_left--; | ||
647 | rd_public_count = convert_records_for_export (rd, | 754 | rd_public_count = convert_records_for_export (rd, |
648 | rd_count, | 755 | rd_count, |
649 | rd_public); | 756 | rd_public); |
@@ -652,25 +759,30 @@ put_gns_record (void *cls, | |||
652 | GNUNET_assert (NULL == zone_publish_task); | 759 | GNUNET_assert (NULL == zone_publish_task); |
653 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 760 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
654 | "Record set empty, moving to next record set\n"); | 761 | "Record set empty, moving to next record set\n"); |
655 | zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_next, | 762 | check_zone_dht_next (); |
656 | NULL); | ||
657 | return; | 763 | return; |
658 | } | 764 | } |
659 | /* We got a set of records to publish */ | 765 | /* We got a set of records to publish */ |
660 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 766 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
661 | "Starting DHT PUT\n"); | 767 | "Starting DHT PUT\n"); |
662 | active_put = perform_dht_put (key, | 768 | ma = GNUNET_new (struct DhtPutActivity); |
663 | label, | 769 | ma->ph = perform_dht_put (key, |
664 | rd_public, | 770 | label, |
665 | rd_public_count, | 771 | rd_public, |
666 | NULL); | 772 | rd_public_count, |
667 | if (NULL == active_put) | 773 | &dht_put_continuation, |
774 | ma); | ||
775 | if (NULL == ma->ph) | ||
668 | { | 776 | { |
669 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 777 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
670 | "Could not perform DHT PUT, is the DHT running?\n"); | 778 | "Could not perform DHT PUT, is the DHT running?\n"); |
671 | dht_put_continuation (NULL, | 779 | GNUNET_free (ma); |
672 | GNUNET_NO); | 780 | check_zone_dht_next (); |
781 | return; | ||
673 | } | 782 | } |
783 | GNUNET_CONTAINER_DLL_insert (it_head, | ||
784 | it_tail, | ||
785 | ma); | ||
674 | } | 786 | } |
675 | 787 | ||
676 | 788 | ||
@@ -693,6 +805,7 @@ publish_zone_dht_start (void *cls) | |||
693 | /* start counting again */ | 805 | /* start counting again */ |
694 | num_public_records = 0; | 806 | num_public_records = 0; |
695 | GNUNET_assert (NULL == namestore_iter); | 807 | GNUNET_assert (NULL == namestore_iter); |
808 | ns_iteration_left = 1; | ||
696 | namestore_iter | 809 | namestore_iter |
697 | = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle, | 810 | = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle, |
698 | NULL, /* All zones */ | 811 | NULL, /* All zones */ |
@@ -724,7 +837,7 @@ handle_monitor_event (void *cls, | |||
724 | { | 837 | { |
725 | struct GNUNET_GNSRECORD_Data rd_public[rd_count]; | 838 | struct GNUNET_GNSRECORD_Data rd_public[rd_count]; |
726 | unsigned int rd_public_count; | 839 | unsigned int rd_public_count; |
727 | struct MonitorActivity *ma; | 840 | struct DhtPutActivity *ma; |
728 | 841 | ||
729 | GNUNET_STATISTICS_update (statistics, | 842 | GNUNET_STATISTICS_update (statistics, |
730 | "Namestore monitor events received", | 843 | "Namestore monitor events received", |
@@ -741,11 +854,12 @@ handle_monitor_event (void *cls, | |||
741 | rd_public); | 854 | rd_public); |
742 | if (0 == rd_public_count) | 855 | if (0 == rd_public_count) |
743 | return; /* nothing to do */ | 856 | return; /* nothing to do */ |
744 | ma = GNUNET_new (struct MonitorActivity); | 857 | ma = GNUNET_new (struct DhtPutActivity); |
745 | ma->ph = perform_dht_put (zone, | 858 | ma->ph = perform_dht_put (zone, |
746 | label, | 859 | label, |
747 | rd, | 860 | rd, |
748 | rd_count, | 861 | rd_count, |
862 | &dht_put_monitor_continuation, | ||
749 | ma); | 863 | ma); |
750 | if (NULL == ma->ph) | 864 | if (NULL == ma->ph) |
751 | { | 865 | { |
@@ -825,6 +939,7 @@ run (void *cls, | |||
825 | unsigned long long max_parallel_bg_queries = 128; | 939 | unsigned long long max_parallel_bg_queries = 128; |
826 | 940 | ||
827 | (void) cls; | 941 | (void) cls; |
942 | last_put_100 = GNUNET_TIME_absolute_get (); /* first time! */ | ||
828 | min_relative_record_time = GNUNET_TIME_UNIT_FOREVER_REL; | 943 | min_relative_record_time = GNUNET_TIME_UNIT_FOREVER_REL; |
829 | namestore_handle = GNUNET_NAMESTORE_connect (c); | 944 | namestore_handle = GNUNET_NAMESTORE_connect (c); |
830 | if (NULL == namestore_handle) | 945 | if (NULL == namestore_handle) |