diff options
Diffstat (limited to 'src/zonemaster/gnunet-service-zonemaster.c')
-rw-r--r-- | src/zonemaster/gnunet-service-zonemaster.c | 794 |
1 files changed, 404 insertions, 390 deletions
diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c index 0d78471aa..a5b21f4a3 100644 --- a/src/zonemaster/gnunet-service-zonemaster.c +++ b/src/zonemaster/gnunet-service-zonemaster.c | |||
@@ -31,7 +31,10 @@ | |||
31 | #include "gnunet_statistics_service.h" | 31 | #include "gnunet_statistics_service.h" |
32 | 32 | ||
33 | 33 | ||
34 | #define LOG_STRERROR_FILE(kind, syscall, filename) GNUNET_log_from_strerror_file(kind, "util", syscall, filename) | 34 | #define LOG_STRERROR_FILE(kind, syscall, \ |
35 | filename) GNUNET_log_from_strerror_file (kind, "util", \ | ||
36 | syscall, \ | ||
37 | filename) | ||
35 | 38 | ||
36 | 39 | ||
37 | /** | 40 | /** |
@@ -73,7 +76,8 @@ | |||
73 | * The upper bound for the zone iteration interval | 76 | * The upper bound for the zone iteration interval |
74 | * (per record). | 77 | * (per record). |
75 | */ | 78 | */ |
76 | #define MAXIMUM_ZONE_ITERATION_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 15) | 79 | #define MAXIMUM_ZONE_ITERATION_INTERVAL GNUNET_TIME_relative_multiply ( \ |
80 | GNUNET_TIME_UNIT_MINUTES, 15) | ||
77 | 81 | ||
78 | /** | 82 | /** |
79 | * The factor the current zone iteration interval is divided by for each | 83 | * The factor the current zone iteration interval is divided by for each |
@@ -90,7 +94,8 @@ | |||
90 | /** | 94 | /** |
91 | * Handle for DHT PUT activity triggered from the namestore monitor. | 95 | * Handle for DHT PUT activity triggered from the namestore monitor. |
92 | */ | 96 | */ |
93 | struct DhtPutActivity { | 97 | struct DhtPutActivity |
98 | { | ||
94 | /** | 99 | /** |
95 | * Kept in a DLL. | 100 | * Kept in a DLL. |
96 | */ | 101 | */ |
@@ -240,49 +245,49 @@ static int cache_keys; | |||
240 | * @param tc unused | 245 | * @param tc unused |
241 | */ | 246 | */ |
242 | static void | 247 | static void |
243 | shutdown_task(void *cls) | 248 | shutdown_task (void *cls) |
244 | { | 249 | { |
245 | struct DhtPutActivity *ma; | 250 | struct DhtPutActivity *ma; |
246 | 251 | ||
247 | (void)cls; | 252 | (void) cls; |
248 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
249 | "Shutting down!\n"); | 254 | "Shutting down!\n"); |
250 | while (NULL != (ma = it_head)) | 255 | while (NULL != (ma = it_head)) |
251 | { | 256 | { |
252 | GNUNET_DHT_put_cancel(ma->ph); | 257 | GNUNET_DHT_put_cancel (ma->ph); |
253 | dht_queue_length--; | 258 | dht_queue_length--; |
254 | GNUNET_CONTAINER_DLL_remove(it_head, | 259 | GNUNET_CONTAINER_DLL_remove (it_head, |
255 | it_tail, | 260 | it_tail, |
256 | ma); | 261 | ma); |
257 | dht_queue_length--; | 262 | dht_queue_length--; |
258 | GNUNET_free(ma); | 263 | GNUNET_free (ma); |
259 | } | 264 | } |
260 | if (NULL != statistics) | 265 | if (NULL != statistics) |
261 | { | 266 | { |
262 | GNUNET_STATISTICS_destroy(statistics, | 267 | GNUNET_STATISTICS_destroy (statistics, |
263 | GNUNET_NO); | 268 | GNUNET_NO); |
264 | statistics = NULL; | 269 | statistics = NULL; |
265 | } | 270 | } |
266 | if (NULL != zone_publish_task) | 271 | if (NULL != zone_publish_task) |
267 | { | 272 | { |
268 | GNUNET_SCHEDULER_cancel(zone_publish_task); | 273 | GNUNET_SCHEDULER_cancel (zone_publish_task); |
269 | zone_publish_task = NULL; | 274 | zone_publish_task = NULL; |
270 | } | 275 | } |
271 | if (NULL != namestore_iter) | 276 | if (NULL != namestore_iter) |
272 | { | 277 | { |
273 | GNUNET_NAMESTORE_zone_iteration_stop(namestore_iter); | 278 | GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter); |
274 | namestore_iter = NULL; | 279 | namestore_iter = NULL; |
275 | } | 280 | } |
276 | if (NULL != namestore_handle) | 281 | if (NULL != namestore_handle) |
277 | { | 282 | { |
278 | GNUNET_NAMESTORE_disconnect(namestore_handle); | 283 | GNUNET_NAMESTORE_disconnect (namestore_handle); |
279 | namestore_handle = NULL; | 284 | namestore_handle = NULL; |
280 | } | 285 | } |
281 | if (NULL != dht_handle) | 286 | if (NULL != dht_handle) |
282 | { | 287 | { |
283 | GNUNET_DHT_disconnect(dht_handle); | 288 | GNUNET_DHT_disconnect (dht_handle); |
284 | dht_handle = NULL; | 289 | dht_handle = NULL; |
285 | } | 290 | } |
286 | } | 291 | } |
287 | 292 | ||
288 | 293 | ||
@@ -292,15 +297,15 @@ shutdown_task(void *cls) | |||
292 | * @param cls NULL | 297 | * @param cls NULL |
293 | */ | 298 | */ |
294 | static void | 299 | static void |
295 | publish_zone_namestore_next(void *cls) | 300 | publish_zone_namestore_next (void *cls) |
296 | { | 301 | { |
297 | (void)cls; | 302 | (void) cls; |
298 | zone_publish_task = NULL; | 303 | zone_publish_task = NULL; |
299 | GNUNET_assert(NULL != namestore_iter); | 304 | GNUNET_assert (NULL != namestore_iter); |
300 | GNUNET_assert(0 == ns_iteration_left); | 305 | GNUNET_assert (0 == ns_iteration_left); |
301 | ns_iteration_left = NS_BLOCK_SIZE; | 306 | ns_iteration_left = NS_BLOCK_SIZE; |
302 | GNUNET_NAMESTORE_zone_iterator_next(namestore_iter, | 307 | GNUNET_NAMESTORE_zone_iterator_next (namestore_iter, |
303 | NS_BLOCK_SIZE); | 308 | NS_BLOCK_SIZE); |
304 | } | 309 | } |
305 | 310 | ||
306 | 311 | ||
@@ -310,54 +315,55 @@ publish_zone_namestore_next(void *cls) | |||
310 | * @param cls NULL | 315 | * @param cls NULL |
311 | */ | 316 | */ |
312 | static void | 317 | static void |
313 | publish_zone_dht_start(void *cls); | 318 | publish_zone_dht_start (void *cls); |
314 | 319 | ||
315 | 320 | ||
316 | /** | 321 | /** |
317 | * Calculate #target_iteration_velocity_per_record. | 322 | * Calculate #target_iteration_velocity_per_record. |
318 | */ | 323 | */ |
319 | static void | 324 | static void |
320 | calculate_put_interval() | 325 | calculate_put_interval () |
321 | { | 326 | { |
322 | if (0 == num_public_records) | 327 | if (0 == num_public_records) |
323 | { | 328 | { |
324 | /** | 329 | /** |
325 | * If no records are known (startup) or none present | 330 | * If no records are known (startup) or none present |
326 | * we can safely set the interval to the value for a single | 331 | * we can safely set the interval to the value for a single |
327 | * record | 332 | * record |
328 | */ | 333 | */ |
329 | target_iteration_velocity_per_record = zone_publish_time_window; | 334 | target_iteration_velocity_per_record = zone_publish_time_window; |
330 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 335 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
331 | "No records in namestore database.\n"); | 336 | "No records in namestore database.\n"); |
332 | } | 337 | } |
333 | else | 338 | else |
334 | { | 339 | { |
335 | last_min_relative_record_time | 340 | last_min_relative_record_time |
336 | = GNUNET_TIME_relative_min(last_min_relative_record_time, | 341 | = GNUNET_TIME_relative_min (last_min_relative_record_time, |
337 | min_relative_record_time); | 342 | min_relative_record_time); |
338 | zone_publish_time_window | 343 | zone_publish_time_window |
339 | = GNUNET_TIME_relative_min(GNUNET_TIME_relative_divide(last_min_relative_record_time, | 344 | = GNUNET_TIME_relative_min (GNUNET_TIME_relative_divide ( |
340 | PUBLISH_OPS_PER_EXPIRATION), | 345 | last_min_relative_record_time, |
341 | zone_publish_time_window_default); | 346 | PUBLISH_OPS_PER_EXPIRATION), |
342 | target_iteration_velocity_per_record | 347 | zone_publish_time_window_default); |
343 | = GNUNET_TIME_relative_divide(zone_publish_time_window, | 348 | target_iteration_velocity_per_record |
344 | last_num_public_records); | 349 | = GNUNET_TIME_relative_divide (zone_publish_time_window, |
345 | } | 350 | last_num_public_records); |
351 | } | ||
346 | target_iteration_velocity_per_record | 352 | target_iteration_velocity_per_record |
347 | = GNUNET_TIME_relative_min(target_iteration_velocity_per_record, | 353 | = GNUNET_TIME_relative_min (target_iteration_velocity_per_record, |
348 | MAXIMUM_ZONE_ITERATION_INTERVAL); | 354 | MAXIMUM_ZONE_ITERATION_INTERVAL); |
349 | GNUNET_STATISTICS_set(statistics, | 355 | GNUNET_STATISTICS_set (statistics, |
350 | "Minimum relative record expiration (in μs)", | 356 | "Minimum relative record expiration (in μs)", |
351 | last_min_relative_record_time.rel_value_us, | 357 | last_min_relative_record_time.rel_value_us, |
352 | GNUNET_NO); | 358 | GNUNET_NO); |
353 | GNUNET_STATISTICS_set(statistics, | 359 | GNUNET_STATISTICS_set (statistics, |
354 | "Zone publication time window (in μs)", | 360 | "Zone publication time window (in μs)", |
355 | zone_publish_time_window.rel_value_us, | 361 | zone_publish_time_window.rel_value_us, |
356 | GNUNET_NO); | 362 | GNUNET_NO); |
357 | GNUNET_STATISTICS_set(statistics, | 363 | GNUNET_STATISTICS_set (statistics, |
358 | "Target zone iteration velocity (μs)", | 364 | "Target zone iteration velocity (μs)", |
359 | target_iteration_velocity_per_record.rel_value_us, | 365 | target_iteration_velocity_per_record.rel_value_us, |
360 | GNUNET_NO); | 366 | GNUNET_NO); |
361 | } | 367 | } |
362 | 368 | ||
363 | 369 | ||
@@ -369,7 +375,7 @@ calculate_put_interval() | |||
369 | * @param cnt how many records were processed since the last call? | 375 | * @param cnt how many records were processed since the last call? |
370 | */ | 376 | */ |
371 | static void | 377 | static void |
372 | update_velocity(unsigned int cnt) | 378 | update_velocity (unsigned int cnt) |
373 | { | 379 | { |
374 | struct GNUNET_TIME_Relative delta; | 380 | struct GNUNET_TIME_Relative delta; |
375 | unsigned long long pct = 0; | 381 | unsigned long long pct = 0; |
@@ -377,88 +383,92 @@ update_velocity(unsigned int cnt) | |||
377 | if (0 == cnt) | 383 | if (0 == cnt) |
378 | return; | 384 | return; |
379 | /* How fast were we really? */ | 385 | /* How fast were we really? */ |
380 | delta = GNUNET_TIME_absolute_get_duration(last_put_100); | 386 | delta = GNUNET_TIME_absolute_get_duration (last_put_100); |
381 | delta.rel_value_us /= cnt; | 387 | delta.rel_value_us /= cnt; |
382 | last_put_100 = GNUNET_TIME_absolute_get(); | 388 | last_put_100 = GNUNET_TIME_absolute_get (); |
383 | 389 | ||
384 | /* calculate expected frequency */ | 390 | /* calculate expected frequency */ |
385 | if ((num_public_records > last_num_public_records) && | 391 | if ((num_public_records > last_num_public_records) && |
386 | (GNUNET_NO == first_zone_iteration)) | 392 | (GNUNET_NO == first_zone_iteration)) |
387 | { | 393 | { |
388 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 394 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
389 | "Last record count was lower than current record count. Reducing interval.\n"); | 395 | "Last record count was lower than current record count. Reducing interval.\n"); |
390 | last_num_public_records = num_public_records * LATE_ITERATION_SPEEDUP_FACTOR; | 396 | last_num_public_records = num_public_records |
391 | calculate_put_interval(); | 397 | * LATE_ITERATION_SPEEDUP_FACTOR; |
392 | } | 398 | calculate_put_interval (); |
393 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 399 | } |
394 | "Desired global zone iteration interval is %s/record!\n", | 400 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
395 | GNUNET_STRINGS_relative_time_to_string(target_iteration_velocity_per_record, | 401 | "Desired global zone iteration interval is %s/record!\n", |
396 | GNUNET_YES)); | 402 | GNUNET_STRINGS_relative_time_to_string ( |
403 | target_iteration_velocity_per_record, | ||
404 | GNUNET_YES)); | ||
397 | 405 | ||
398 | /* Tell statistics actual vs. desired speed */ | 406 | /* Tell statistics actual vs. desired speed */ |
399 | GNUNET_STATISTICS_set(statistics, | 407 | GNUNET_STATISTICS_set (statistics, |
400 | "Current zone iteration velocity (μs/record)", | 408 | "Current zone iteration velocity (μs/record)", |
401 | delta.rel_value_us, | 409 | delta.rel_value_us, |
402 | GNUNET_NO); | 410 | GNUNET_NO); |
403 | /* update "sub_delta" based on difference, taking | 411 | /* update "sub_delta" based on difference, taking |
404 | previous sub_delta into account! */ | 412 | previous sub_delta into account! */ |
405 | if (target_iteration_velocity_per_record.rel_value_us > delta.rel_value_us) | 413 | if (target_iteration_velocity_per_record.rel_value_us > delta.rel_value_us) |
414 | { | ||
415 | /* We were too fast, reduce sub_delta! */ | ||
416 | struct GNUNET_TIME_Relative corr; | ||
417 | |||
418 | corr = GNUNET_TIME_relative_subtract (target_iteration_velocity_per_record, | ||
419 | delta); | ||
420 | if (sub_delta.rel_value_us > delta.rel_value_us) | ||
406 | { | 421 | { |
407 | /* We were too fast, reduce sub_delta! */ | 422 | /* Reduce sub_delta by corr */ |
408 | struct GNUNET_TIME_Relative corr; | 423 | sub_delta = GNUNET_TIME_relative_subtract (sub_delta, |
409 | 424 | corr); | |
410 | corr = GNUNET_TIME_relative_subtract(target_iteration_velocity_per_record, | ||
411 | delta); | ||
412 | if (sub_delta.rel_value_us > delta.rel_value_us) | ||
413 | { | ||
414 | /* Reduce sub_delta by corr */ | ||
415 | sub_delta = GNUNET_TIME_relative_subtract(sub_delta, | ||
416 | corr); | ||
417 | } | ||
418 | else | ||
419 | { | ||
420 | /* We're doing fine with waiting the full time, this | ||
421 | should theoretically only happen if we run at | ||
422 | infinite speed. */ | ||
423 | sub_delta = GNUNET_TIME_UNIT_ZERO; | ||
424 | } | ||
425 | } | 425 | } |
426 | else if (target_iteration_velocity_per_record.rel_value_us < delta.rel_value_us) | 426 | else |
427 | { | 427 | { |
428 | /* We were too slow, increase sub_delta! */ | 428 | /* We're doing fine with waiting the full time, this |
429 | struct GNUNET_TIME_Relative corr; | 429 | should theoretically only happen if we run at |
430 | 430 | infinite speed. */ | |
431 | corr = GNUNET_TIME_relative_subtract(delta, | 431 | sub_delta = GNUNET_TIME_UNIT_ZERO; |
432 | target_iteration_velocity_per_record); | ||
433 | sub_delta = GNUNET_TIME_relative_add(sub_delta, | ||
434 | corr); | ||
435 | if (sub_delta.rel_value_us > target_iteration_velocity_per_record.rel_value_us) | ||
436 | { | ||
437 | /* CPU overload detected, we cannot go at desired speed, | ||
438 | as this would mean using a negative delay. */ | ||
439 | /* compute how much faster we would want to be for | ||
440 | the desired velocity */ | ||
441 | if (0 == target_iteration_velocity_per_record.rel_value_us) | ||
442 | pct = UINT64_MAX; /* desired speed is infinity ... */ | ||
443 | else | ||
444 | pct = (sub_delta.rel_value_us - | ||
445 | target_iteration_velocity_per_record.rel_value_us) * 100LLU | ||
446 | / target_iteration_velocity_per_record.rel_value_us; | ||
447 | sub_delta = target_iteration_velocity_per_record; | ||
448 | } | ||
449 | } | 432 | } |
450 | GNUNET_STATISTICS_set(statistics, | 433 | } |
451 | "# size of the DHT queue (it)", | 434 | else if (target_iteration_velocity_per_record.rel_value_us < |
452 | dht_queue_length, | 435 | delta.rel_value_us) |
453 | GNUNET_NO); | 436 | { |
454 | GNUNET_STATISTICS_set(statistics, | 437 | /* We were too slow, increase sub_delta! */ |
455 | "% speed increase needed for target velocity", | 438 | struct GNUNET_TIME_Relative corr; |
456 | pct, | 439 | |
457 | GNUNET_NO); | 440 | corr = GNUNET_TIME_relative_subtract (delta, |
458 | GNUNET_STATISTICS_set(statistics, | 441 | target_iteration_velocity_per_record); |
459 | "# records processed in current iteration", | 442 | sub_delta = GNUNET_TIME_relative_add (sub_delta, |
460 | num_public_records, | 443 | corr); |
461 | GNUNET_NO); | 444 | if (sub_delta.rel_value_us > |
445 | target_iteration_velocity_per_record.rel_value_us) | ||
446 | { | ||
447 | /* CPU overload detected, we cannot go at desired speed, | ||
448 | as this would mean using a negative delay. */ | ||
449 | /* compute how much faster we would want to be for | ||
450 | the desired velocity */ | ||
451 | if (0 == target_iteration_velocity_per_record.rel_value_us) | ||
452 | pct = UINT64_MAX; /* desired speed is infinity ... */ | ||
453 | else | ||
454 | pct = (sub_delta.rel_value_us | ||
455 | - target_iteration_velocity_per_record.rel_value_us) * 100LLU | ||
456 | / target_iteration_velocity_per_record.rel_value_us; | ||
457 | sub_delta = target_iteration_velocity_per_record; | ||
458 | } | ||
459 | } | ||
460 | GNUNET_STATISTICS_set (statistics, | ||
461 | "# size of the DHT queue (it)", | ||
462 | dht_queue_length, | ||
463 | GNUNET_NO); | ||
464 | GNUNET_STATISTICS_set (statistics, | ||
465 | "% speed increase needed for target velocity", | ||
466 | pct, | ||
467 | GNUNET_NO); | ||
468 | GNUNET_STATISTICS_set (statistics, | ||
469 | "# records processed in current iteration", | ||
470 | num_public_records, | ||
471 | GNUNET_NO); | ||
462 | } | 472 | } |
463 | 473 | ||
464 | 474 | ||
@@ -467,34 +477,34 @@ update_velocity(unsigned int cnt) | |||
467 | * by calling #publish_zone_namestore_next(), and if so with what delay. | 477 | * by calling #publish_zone_namestore_next(), and if so with what delay. |
468 | */ | 478 | */ |
469 | static void | 479 | static void |
470 | check_zone_namestore_next() | 480 | check_zone_namestore_next () |
471 | { | 481 | { |
472 | struct GNUNET_TIME_Relative delay; | 482 | struct GNUNET_TIME_Relative delay; |
473 | 483 | ||
474 | if (0 != ns_iteration_left) | 484 | if (0 != ns_iteration_left) |
475 | return; /* current NAMESTORE iteration not yet done */ | 485 | return; /* current NAMESTORE iteration not yet done */ |
476 | update_velocity(put_cnt); | 486 | update_velocity (put_cnt); |
477 | put_cnt = 0; | 487 | put_cnt = 0; |
478 | delay = GNUNET_TIME_relative_subtract(target_iteration_velocity_per_record, | 488 | delay = GNUNET_TIME_relative_subtract (target_iteration_velocity_per_record, |
479 | sub_delta); | 489 | sub_delta); |
480 | /* We delay *once* per #NS_BLOCK_SIZE, so we need to multiply the | 490 | /* We delay *once* per #NS_BLOCK_SIZE, so we need to multiply the |
481 | per-record delay calculated so far with the #NS_BLOCK_SIZE */ | 491 | per-record delay calculated so far with the #NS_BLOCK_SIZE */ |
482 | GNUNET_STATISTICS_set(statistics, | 492 | GNUNET_STATISTICS_set (statistics, |
483 | "Current artificial NAMESTORE delay (μs/record)", | 493 | "Current artificial NAMESTORE delay (μs/record)", |
484 | delay.rel_value_us, | 494 | delay.rel_value_us, |
485 | GNUNET_NO); | 495 | GNUNET_NO); |
486 | delay = GNUNET_TIME_relative_multiply(delay, | 496 | delay = GNUNET_TIME_relative_multiply (delay, |
487 | NS_BLOCK_SIZE); | 497 | NS_BLOCK_SIZE); |
488 | /* make sure we do not overshoot because of the #NS_BLOCK_SIZE factor */ | 498 | /* make sure we do not overshoot because of the #NS_BLOCK_SIZE factor */ |
489 | delay = GNUNET_TIME_relative_min(MAXIMUM_ZONE_ITERATION_INTERVAL, | 499 | delay = GNUNET_TIME_relative_min (MAXIMUM_ZONE_ITERATION_INTERVAL, |
490 | delay); | 500 | delay); |
491 | /* no delays on first iteration */ | 501 | /* no delays on first iteration */ |
492 | if (GNUNET_YES == first_zone_iteration) | 502 | if (GNUNET_YES == first_zone_iteration) |
493 | delay = GNUNET_TIME_UNIT_ZERO; | 503 | delay = GNUNET_TIME_UNIT_ZERO; |
494 | GNUNET_assert(NULL == zone_publish_task); | 504 | GNUNET_assert (NULL == zone_publish_task); |
495 | zone_publish_task = GNUNET_SCHEDULER_add_delayed(delay, | 505 | zone_publish_task = GNUNET_SCHEDULER_add_delayed (delay, |
496 | &publish_zone_namestore_next, | 506 | &publish_zone_namestore_next, |
497 | NULL); | 507 | NULL); |
498 | } | 508 | } |
499 | 509 | ||
500 | 510 | ||
@@ -504,17 +514,17 @@ check_zone_namestore_next() | |||
504 | * @param cls a `struct DhtPutActivity` | 514 | * @param cls a `struct DhtPutActivity` |
505 | */ | 515 | */ |
506 | static void | 516 | static void |
507 | dht_put_continuation(void *cls) | 517 | dht_put_continuation (void *cls) |
508 | { | 518 | { |
509 | struct DhtPutActivity *ma = cls; | 519 | struct DhtPutActivity *ma = cls; |
510 | 520 | ||
511 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
512 | "PUT complete\n"); | 522 | "PUT complete\n"); |
513 | dht_queue_length--; | 523 | dht_queue_length--; |
514 | GNUNET_CONTAINER_DLL_remove(it_head, | 524 | GNUNET_CONTAINER_DLL_remove (it_head, |
515 | it_tail, | 525 | it_tail, |
516 | ma); | 526 | ma); |
517 | GNUNET_free(ma); | 527 | GNUNET_free (ma); |
518 | } | 528 | } |
519 | 529 | ||
520 | 530 | ||
@@ -529,32 +539,32 @@ dht_put_continuation(void *cls) | |||
529 | * @return number of records written to @a rd_public | 539 | * @return number of records written to @a rd_public |
530 | */ | 540 | */ |
531 | static unsigned int | 541 | static unsigned int |
532 | convert_records_for_export(const struct GNUNET_GNSRECORD_Data *rd, | 542 | convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd, |
533 | unsigned int rd_count, | 543 | unsigned int rd_count, |
534 | struct GNUNET_GNSRECORD_Data *rd_public) | 544 | struct GNUNET_GNSRECORD_Data *rd_public) |
535 | { | 545 | { |
536 | struct GNUNET_TIME_Absolute now; | 546 | struct GNUNET_TIME_Absolute now; |
537 | unsigned int rd_public_count; | 547 | unsigned int rd_public_count; |
538 | 548 | ||
539 | rd_public_count = 0; | 549 | rd_public_count = 0; |
540 | now = GNUNET_TIME_absolute_get(); | 550 | now = GNUNET_TIME_absolute_get (); |
541 | for (unsigned int i = 0; i < rd_count; i++) | 551 | for (unsigned int i = 0; i < rd_count; i++) |
552 | { | ||
553 | if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) | ||
554 | continue; | ||
555 | if ((0 == (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) && | ||
556 | (rd[i].expiration_time < now.abs_value_us)) | ||
557 | continue; /* record already expired, skip it */ | ||
558 | if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) | ||
542 | { | 559 | { |
543 | if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) | 560 | /* GNUNET_GNSRECORD_block_create will convert to absolute time; |
544 | continue; | 561 | we just need to adjust our iteration frequency */ |
545 | if ((0 == (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) && | 562 | min_relative_record_time.rel_value_us = |
546 | (rd[i].expiration_time < now.abs_value_us)) | 563 | GNUNET_MIN (rd[i].expiration_time, |
547 | continue; /* record already expired, skip it */ | 564 | min_relative_record_time.rel_value_us); |
548 | if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) | ||
549 | { | ||
550 | /* GNUNET_GNSRECORD_block_create will convert to absolute time; | ||
551 | we just need to adjust our iteration frequency */ | ||
552 | min_relative_record_time.rel_value_us = | ||
553 | GNUNET_MIN(rd[i].expiration_time, | ||
554 | min_relative_record_time.rel_value_us); | ||
555 | } | ||
556 | rd_public[rd_public_count++] = rd[i]; | ||
557 | } | 565 | } |
566 | rd_public[rd_public_count++] = rd[i]; | ||
567 | } | ||
558 | return rd_public_count; | 568 | return rd_public_count; |
559 | } | 569 | } |
560 | 570 | ||
@@ -570,11 +580,11 @@ convert_records_for_export(const struct GNUNET_GNSRECORD_Data *rd, | |||
570 | * @return DHT PUT handle, NULL on error | 580 | * @return DHT PUT handle, NULL on error |
571 | */ | 581 | */ |
572 | static struct GNUNET_DHT_PutHandle * | 582 | static struct GNUNET_DHT_PutHandle * |
573 | perform_dht_put(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 583 | perform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, |
574 | const char *label, | 584 | const char *label, |
575 | const struct GNUNET_GNSRECORD_Data *rd_public, | 585 | const struct GNUNET_GNSRECORD_Data *rd_public, |
576 | unsigned int rd_public_count, | 586 | unsigned int rd_public_count, |
577 | struct DhtPutActivity *ma) | 587 | struct DhtPutActivity *ma) |
578 | { | 588 | { |
579 | struct GNUNET_GNSRECORD_Block *block; | 589 | struct GNUNET_GNSRECORD_Block *block; |
580 | struct GNUNET_HashCode query; | 590 | struct GNUNET_HashCode query; |
@@ -582,53 +592,53 @@ perform_dht_put(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
582 | size_t block_size; | 592 | size_t block_size; |
583 | struct GNUNET_DHT_PutHandle *ret; | 593 | struct GNUNET_DHT_PutHandle *ret; |
584 | 594 | ||
585 | expire = GNUNET_GNSRECORD_record_get_expiration_time(rd_public_count, | 595 | expire = GNUNET_GNSRECORD_record_get_expiration_time (rd_public_count, |
586 | rd_public); | 596 | rd_public); |
587 | if (cache_keys) | 597 | if (cache_keys) |
588 | block = GNUNET_GNSRECORD_block_create2(key, | 598 | block = GNUNET_GNSRECORD_block_create2 (key, |
599 | expire, | ||
600 | label, | ||
601 | rd_public, | ||
602 | rd_public_count); | ||
603 | else | ||
604 | block = GNUNET_GNSRECORD_block_create (key, | ||
589 | expire, | 605 | expire, |
590 | label, | 606 | label, |
591 | rd_public, | 607 | rd_public, |
592 | rd_public_count); | 608 | rd_public_count); |
593 | else | ||
594 | block = GNUNET_GNSRECORD_block_create(key, | ||
595 | expire, | ||
596 | label, | ||
597 | rd_public, | ||
598 | rd_public_count); | ||
599 | if (NULL == block) | 609 | if (NULL == block) |
600 | { | 610 | { |
601 | GNUNET_break(0); | 611 | GNUNET_break (0); |
602 | return NULL; /* whoops */ | 612 | return NULL; /* whoops */ |
603 | } | 613 | } |
604 | block_size = ntohl(block->purpose.size) | 614 | block_size = ntohl (block->purpose.size) |
605 | + sizeof(struct GNUNET_CRYPTO_EcdsaSignature) | 615 | + sizeof(struct GNUNET_CRYPTO_EcdsaSignature) |
606 | + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey); | 616 | + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey); |
607 | GNUNET_GNSRECORD_query_from_private_key(key, | 617 | GNUNET_GNSRECORD_query_from_private_key (key, |
608 | label, | 618 | label, |
609 | &query); | 619 | &query); |
610 | GNUNET_STATISTICS_update(statistics, | 620 | GNUNET_STATISTICS_update (statistics, |
611 | "DHT put operations initiated", | 621 | "DHT put operations initiated", |
612 | 1, | 622 | 1, |
613 | GNUNET_NO); | 623 | GNUNET_NO); |
614 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 624 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
615 | "Storing %u record(s) for label `%s' in DHT with expiration `%s' under key %s\n", | 625 | "Storing %u record(s) for label `%s' in DHT with expiration `%s' under key %s\n", |
616 | rd_public_count, | 626 | rd_public_count, |
617 | label, | 627 | label, |
618 | GNUNET_STRINGS_absolute_time_to_string(expire), | 628 | GNUNET_STRINGS_absolute_time_to_string (expire), |
619 | GNUNET_h2s(&query)); | 629 | GNUNET_h2s (&query)); |
620 | num_public_records++; | 630 | num_public_records++; |
621 | ret = GNUNET_DHT_put(dht_handle, | 631 | ret = GNUNET_DHT_put (dht_handle, |
622 | &query, | 632 | &query, |
623 | DHT_GNS_REPLICATION_LEVEL, | 633 | DHT_GNS_REPLICATION_LEVEL, |
624 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, | 634 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, |
625 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD, | 635 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD, |
626 | block_size, | 636 | block_size, |
627 | block, | 637 | block, |
628 | expire, | 638 | expire, |
629 | &dht_put_continuation, | 639 | &dht_put_continuation, |
630 | ma); | 640 | ma); |
631 | GNUNET_free(block); | 641 | GNUNET_free (block); |
632 | return ret; | 642 | return ret; |
633 | } | 643 | } |
634 | 644 | ||
@@ -639,22 +649,22 @@ perform_dht_put(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
639 | * @param cls NULL | 649 | * @param cls NULL |
640 | */ | 650 | */ |
641 | static void | 651 | static void |
642 | zone_iteration_error(void *cls) | 652 | zone_iteration_error (void *cls) |
643 | { | 653 | { |
644 | (void)cls; | 654 | (void) cls; |
645 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
646 | "Got disconnected from namestore database, retrying.\n"); | 656 | "Got disconnected from namestore database, retrying.\n"); |
647 | namestore_iter = NULL; | 657 | namestore_iter = NULL; |
648 | /* We end up here on error/disconnect/shutdown, so potentially | 658 | /* We end up here on error/disconnect/shutdown, so potentially |
649 | while a zone publish task or a DHT put is still running; hence | 659 | while a zone publish task or a DHT put is still running; hence |
650 | we need to cancel those. */ | 660 | we need to cancel those. */ |
651 | if (NULL != zone_publish_task) | 661 | if (NULL != zone_publish_task) |
652 | { | 662 | { |
653 | GNUNET_SCHEDULER_cancel(zone_publish_task); | 663 | GNUNET_SCHEDULER_cancel (zone_publish_task); |
654 | zone_publish_task = NULL; | 664 | zone_publish_task = NULL; |
655 | } | 665 | } |
656 | zone_publish_task = GNUNET_SCHEDULER_add_now(&publish_zone_dht_start, | 666 | zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, |
657 | NULL); | 667 | NULL); |
658 | } | 668 | } |
659 | 669 | ||
660 | 670 | ||
@@ -664,42 +674,44 @@ zone_iteration_error(void *cls) | |||
664 | * @param cls NULL | 674 | * @param cls NULL |
665 | */ | 675 | */ |
666 | static void | 676 | static void |
667 | zone_iteration_finished(void *cls) | 677 | zone_iteration_finished (void *cls) |
668 | { | 678 | { |
669 | (void)cls; | 679 | (void) cls; |
670 | /* we're done with one iteration, calculate when to do the next one */ | 680 | /* we're done with one iteration, calculate when to do the next one */ |
671 | namestore_iter = NULL; | 681 | namestore_iter = NULL; |
672 | last_num_public_records = num_public_records; | 682 | last_num_public_records = num_public_records; |
673 | first_zone_iteration = GNUNET_NO; | 683 | first_zone_iteration = GNUNET_NO; |
674 | last_min_relative_record_time = min_relative_record_time; | 684 | last_min_relative_record_time = min_relative_record_time; |
675 | calculate_put_interval(); | 685 | calculate_put_interval (); |
676 | /* reset for next iteration */ | 686 | /* reset for next iteration */ |
677 | min_relative_record_time | 687 | min_relative_record_time |
678 | = GNUNET_TIME_UNIT_FOREVER_REL; | 688 | = GNUNET_TIME_UNIT_FOREVER_REL; |
679 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 689 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
680 | "Zone iteration finished. Adjusted zone iteration interval to %s\n", | 690 | "Zone iteration finished. Adjusted zone iteration interval to %s\n", |
681 | GNUNET_STRINGS_relative_time_to_string(target_iteration_velocity_per_record, | 691 | GNUNET_STRINGS_relative_time_to_string ( |
682 | GNUNET_YES)); | 692 | target_iteration_velocity_per_record, |
683 | GNUNET_STATISTICS_set(statistics, | 693 | GNUNET_YES)); |
684 | "Target zone iteration velocity (μs)", | 694 | GNUNET_STATISTICS_set (statistics, |
685 | target_iteration_velocity_per_record.rel_value_us, | 695 | "Target zone iteration velocity (μs)", |
686 | GNUNET_NO); | 696 | target_iteration_velocity_per_record.rel_value_us, |
687 | GNUNET_STATISTICS_set(statistics, | 697 | GNUNET_NO); |
688 | "Number of public records in DHT", | 698 | GNUNET_STATISTICS_set (statistics, |
689 | last_num_public_records, | 699 | "Number of public records in DHT", |
690 | GNUNET_NO); | 700 | last_num_public_records, |
691 | GNUNET_assert(NULL == zone_publish_task); | 701 | GNUNET_NO); |
702 | GNUNET_assert (NULL == zone_publish_task); | ||
692 | if (0 == last_num_public_records) | 703 | if (0 == last_num_public_records) |
693 | { | 704 | { |
694 | zone_publish_task = GNUNET_SCHEDULER_add_delayed(target_iteration_velocity_per_record, | 705 | zone_publish_task = GNUNET_SCHEDULER_add_delayed ( |
695 | &publish_zone_dht_start, | 706 | target_iteration_velocity_per_record, |
696 | NULL); | 707 | &publish_zone_dht_start, |
697 | } | 708 | NULL); |
709 | } | ||
698 | else | 710 | else |
699 | { | 711 | { |
700 | zone_publish_task = GNUNET_SCHEDULER_add_now(&publish_zone_dht_start, | 712 | zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, |
701 | NULL); | 713 | NULL); |
702 | } | 714 | } |
703 | } | 715 | } |
704 | 716 | ||
705 | 717 | ||
@@ -713,67 +725,68 @@ zone_iteration_finished(void *cls) | |||
713 | * @param rd the record data | 725 | * @param rd the record data |
714 | */ | 726 | */ |
715 | static void | 727 | static void |
716 | put_gns_record(void *cls, | 728 | put_gns_record (void *cls, |
717 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 729 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, |
718 | const char *label, | 730 | const char *label, |
719 | unsigned int rd_count, | 731 | unsigned int rd_count, |
720 | const struct GNUNET_GNSRECORD_Data *rd) | 732 | const struct GNUNET_GNSRECORD_Data *rd) |
721 | { | 733 | { |
722 | struct GNUNET_GNSRECORD_Data rd_public[rd_count]; | 734 | struct GNUNET_GNSRECORD_Data rd_public[rd_count]; |
723 | unsigned int rd_public_count; | 735 | unsigned int rd_public_count; |
724 | struct DhtPutActivity *ma; | 736 | struct DhtPutActivity *ma; |
725 | 737 | ||
726 | (void)cls; | 738 | (void) cls; |
727 | ns_iteration_left--; | 739 | ns_iteration_left--; |
728 | rd_public_count = convert_records_for_export(rd, | 740 | rd_public_count = convert_records_for_export (rd, |
729 | rd_count, | 741 | rd_count, |
730 | rd_public); | 742 | rd_public); |
731 | if (0 == rd_public_count) | 743 | if (0 == rd_public_count) |
732 | { | 744 | { |
733 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 745 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
734 | "Record set empty, moving to next record set\n"); | 746 | "Record set empty, moving to next record set\n"); |
735 | check_zone_namestore_next(); | 747 | check_zone_namestore_next (); |
736 | return; | 748 | return; |
737 | } | 749 | } |
738 | /* We got a set of records to publish */ | 750 | /* We got a set of records to publish */ |
739 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 751 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
740 | "Starting DHT PUT\n"); | 752 | "Starting DHT PUT\n"); |
741 | ma = GNUNET_new(struct DhtPutActivity); | 753 | ma = GNUNET_new (struct DhtPutActivity); |
742 | ma->start_date = GNUNET_TIME_absolute_get(); | 754 | ma->start_date = GNUNET_TIME_absolute_get (); |
743 | ma->ph = perform_dht_put(key, | 755 | ma->ph = perform_dht_put (key, |
744 | label, | 756 | label, |
745 | rd_public, | 757 | rd_public, |
746 | rd_public_count, | 758 | rd_public_count, |
747 | ma); | 759 | ma); |
748 | put_cnt++; | 760 | put_cnt++; |
749 | if (0 == put_cnt % DELTA_INTERVAL) | 761 | if (0 == put_cnt % DELTA_INTERVAL) |
750 | update_velocity(DELTA_INTERVAL); | 762 | update_velocity (DELTA_INTERVAL); |
751 | check_zone_namestore_next(); | 763 | check_zone_namestore_next (); |
752 | if (NULL == ma->ph) | 764 | if (NULL == ma->ph) |
753 | { | 765 | { |
754 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 766 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
755 | "Could not perform DHT PUT, is the DHT running?\n"); | 767 | "Could not perform DHT PUT, is the DHT running?\n"); |
756 | GNUNET_free(ma); | 768 | GNUNET_free (ma); |
757 | return; | 769 | return; |
758 | } | 770 | } |
759 | dht_queue_length++; | 771 | dht_queue_length++; |
760 | GNUNET_CONTAINER_DLL_insert_tail(it_head, | 772 | GNUNET_CONTAINER_DLL_insert_tail (it_head, |
761 | it_tail, | 773 | it_tail, |
762 | ma); | 774 | ma); |
763 | if (dht_queue_length > DHT_QUEUE_LIMIT) | 775 | if (dht_queue_length > DHT_QUEUE_LIMIT) |
764 | { | 776 | { |
765 | ma = it_head; | 777 | ma = it_head; |
766 | GNUNET_CONTAINER_DLL_remove(it_head, | 778 | GNUNET_CONTAINER_DLL_remove (it_head, |
767 | it_tail, | 779 | it_tail, |
768 | ma); | 780 | ma); |
769 | GNUNET_DHT_put_cancel(ma->ph); | 781 | GNUNET_DHT_put_cancel (ma->ph); |
770 | dht_queue_length--; | 782 | dht_queue_length--; |
771 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 783 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
772 | "DHT PUT unconfirmed after %s, aborting PUT\n", | 784 | "DHT PUT unconfirmed after %s, aborting PUT\n", |
773 | GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_duration(ma->start_date), | 785 | GNUNET_STRINGS_relative_time_to_string ( |
774 | GNUNET_YES)); | 786 | GNUNET_TIME_absolute_get_duration (ma->start_date), |
775 | GNUNET_free(ma); | 787 | GNUNET_YES)); |
776 | } | 788 | GNUNET_free (ma); |
789 | } | ||
777 | } | 790 | } |
778 | 791 | ||
779 | 792 | ||
@@ -783,30 +796,30 @@ put_gns_record(void *cls, | |||
783 | * @param cls NULL | 796 | * @param cls NULL |
784 | */ | 797 | */ |
785 | static void | 798 | static void |
786 | publish_zone_dht_start(void *cls) | 799 | publish_zone_dht_start (void *cls) |
787 | { | 800 | { |
788 | (void)cls; | 801 | (void) cls; |
789 | zone_publish_task = NULL; | 802 | zone_publish_task = NULL; |
790 | GNUNET_STATISTICS_update(statistics, | 803 | GNUNET_STATISTICS_update (statistics, |
791 | "Full zone iterations launched", | 804 | "Full zone iterations launched", |
792 | 1, | 805 | 1, |
793 | GNUNET_NO); | 806 | GNUNET_NO); |
794 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 807 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
795 | "Starting DHT zone update!\n"); | 808 | "Starting DHT zone update!\n"); |
796 | /* start counting again */ | 809 | /* start counting again */ |
797 | num_public_records = 0; | 810 | num_public_records = 0; |
798 | GNUNET_assert(NULL == namestore_iter); | 811 | GNUNET_assert (NULL == namestore_iter); |
799 | ns_iteration_left = 1; | 812 | ns_iteration_left = 1; |
800 | namestore_iter | 813 | namestore_iter |
801 | = GNUNET_NAMESTORE_zone_iteration_start(namestore_handle, | 814 | = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle, |
802 | NULL, /* All zones */ | 815 | NULL, /* All zones */ |
803 | &zone_iteration_error, | 816 | &zone_iteration_error, |
804 | NULL, | 817 | NULL, |
805 | &put_gns_record, | 818 | &put_gns_record, |
806 | NULL, | 819 | NULL, |
807 | &zone_iteration_finished, | 820 | &zone_iteration_finished, |
808 | NULL); | 821 | NULL); |
809 | GNUNET_assert(NULL != namestore_iter); | 822 | GNUNET_assert (NULL != namestore_iter); |
810 | } | 823 | } |
811 | 824 | ||
812 | 825 | ||
@@ -818,77 +831,78 @@ publish_zone_dht_start(void *cls) | |||
818 | * @param c configuration to use | 831 | * @param c configuration to use |
819 | */ | 832 | */ |
820 | static void | 833 | static void |
821 | run(void *cls, | 834 | run (void *cls, |
822 | const struct GNUNET_CONFIGURATION_Handle *c, | 835 | const struct GNUNET_CONFIGURATION_Handle *c, |
823 | struct GNUNET_SERVICE_Handle *service) | 836 | struct GNUNET_SERVICE_Handle *service) |
824 | { | 837 | { |
825 | unsigned long long max_parallel_bg_queries = 128; | 838 | unsigned long long max_parallel_bg_queries = 128; |
826 | 839 | ||
827 | (void)cls; | 840 | (void) cls; |
828 | (void)service; | 841 | (void) service; |
829 | last_put_100 = GNUNET_TIME_absolute_get(); /* first time! */ | 842 | last_put_100 = GNUNET_TIME_absolute_get (); /* first time! */ |
830 | min_relative_record_time | 843 | min_relative_record_time |
831 | = GNUNET_TIME_UNIT_FOREVER_REL; | 844 | = GNUNET_TIME_UNIT_FOREVER_REL; |
832 | target_iteration_velocity_per_record = INITIAL_ZONE_ITERATION_INTERVAL; | 845 | target_iteration_velocity_per_record = INITIAL_ZONE_ITERATION_INTERVAL; |
833 | namestore_handle = GNUNET_NAMESTORE_connect(c); | 846 | namestore_handle = GNUNET_NAMESTORE_connect (c); |
834 | if (NULL == namestore_handle) | 847 | if (NULL == namestore_handle) |
835 | { | 848 | { |
836 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 849 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
837 | _("Failed to connect to the namestore!\n")); | 850 | _ ("Failed to connect to the namestore!\n")); |
838 | GNUNET_SCHEDULER_shutdown(); | 851 | GNUNET_SCHEDULER_shutdown (); |
839 | return; | 852 | return; |
840 | } | 853 | } |
841 | cache_keys = GNUNET_CONFIGURATION_get_value_yesno(c, | 854 | cache_keys = GNUNET_CONFIGURATION_get_value_yesno (c, |
842 | "namestore", | 855 | "namestore", |
843 | "CACHE_KEYS"); | 856 | "CACHE_KEYS"); |
844 | zone_publish_time_window_default = GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY; | 857 | zone_publish_time_window_default = GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY; |
845 | if (GNUNET_OK == | 858 | if (GNUNET_OK == |
846 | GNUNET_CONFIGURATION_get_value_time(c, | 859 | GNUNET_CONFIGURATION_get_value_time (c, |
847 | "zonemaster", | 860 | "zonemaster", |
848 | "ZONE_PUBLISH_TIME_WINDOW", | 861 | "ZONE_PUBLISH_TIME_WINDOW", |
849 | &zone_publish_time_window_default)) | 862 | &zone_publish_time_window_default)) |
850 | { | 863 | { |
851 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 864 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
852 | "Time window for zone iteration: %s\n", | 865 | "Time window for zone iteration: %s\n", |
853 | GNUNET_STRINGS_relative_time_to_string(zone_publish_time_window, | 866 | GNUNET_STRINGS_relative_time_to_string ( |
854 | GNUNET_YES)); | 867 | zone_publish_time_window, |
855 | } | 868 | GNUNET_YES)); |
869 | } | ||
856 | zone_publish_time_window = zone_publish_time_window_default; | 870 | zone_publish_time_window = zone_publish_time_window_default; |
857 | if (GNUNET_OK == | 871 | if (GNUNET_OK == |
858 | GNUNET_CONFIGURATION_get_value_number(c, | 872 | GNUNET_CONFIGURATION_get_value_number (c, |
859 | "zonemaster", | 873 | "zonemaster", |
860 | "MAX_PARALLEL_BACKGROUND_QUERIES", | 874 | "MAX_PARALLEL_BACKGROUND_QUERIES", |
861 | &max_parallel_bg_queries)) | 875 | &max_parallel_bg_queries)) |
862 | { | 876 | { |
863 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 877 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
864 | "Number of allowed parallel background queries: %llu\n", | 878 | "Number of allowed parallel background queries: %llu\n", |
865 | max_parallel_bg_queries); | 879 | max_parallel_bg_queries); |
866 | } | 880 | } |
867 | if (0 == max_parallel_bg_queries) | 881 | if (0 == max_parallel_bg_queries) |
868 | max_parallel_bg_queries = 1; | 882 | max_parallel_bg_queries = 1; |
869 | dht_handle = GNUNET_DHT_connect(c, | 883 | dht_handle = GNUNET_DHT_connect (c, |
870 | (unsigned int)max_parallel_bg_queries); | 884 | (unsigned int) max_parallel_bg_queries); |
871 | if (NULL == dht_handle) | 885 | if (NULL == dht_handle) |
872 | { | 886 | { |
873 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 887 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
874 | _("Could not connect to DHT!\n")); | 888 | _ ("Could not connect to DHT!\n")); |
875 | GNUNET_SCHEDULER_add_now(&shutdown_task, | 889 | GNUNET_SCHEDULER_add_now (&shutdown_task, |
876 | NULL); | 890 | NULL); |
877 | return; | 891 | return; |
878 | } | 892 | } |
879 | 893 | ||
880 | /* Schedule periodic put for our records. */ | 894 | /* Schedule periodic put for our records. */ |
881 | first_zone_iteration = GNUNET_YES; | 895 | first_zone_iteration = GNUNET_YES; |
882 | statistics = GNUNET_STATISTICS_create("zonemaster", | 896 | statistics = GNUNET_STATISTICS_create ("zonemaster", |
883 | c); | 897 | c); |
884 | GNUNET_STATISTICS_set(statistics, | 898 | GNUNET_STATISTICS_set (statistics, |
885 | "Target zone iteration velocity (μs)", | 899 | "Target zone iteration velocity (μs)", |
886 | target_iteration_velocity_per_record.rel_value_us, | 900 | target_iteration_velocity_per_record.rel_value_us, |
887 | GNUNET_NO); | 901 | GNUNET_NO); |
888 | zone_publish_task = GNUNET_SCHEDULER_add_now(&publish_zone_dht_start, | 902 | zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, |
889 | NULL); | 903 | NULL); |
890 | GNUNET_SCHEDULER_add_shutdown(&shutdown_task, | 904 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
891 | NULL); | 905 | NULL); |
892 | } | 906 | } |
893 | 907 | ||
894 | 908 | ||
@@ -902,7 +916,7 @@ GNUNET_SERVICE_MAIN | |||
902 | NULL, | 916 | NULL, |
903 | NULL, | 917 | NULL, |
904 | NULL, | 918 | NULL, |
905 | GNUNET_MQ_handler_end()); | 919 | GNUNET_MQ_handler_end ()); |
906 | 920 | ||
907 | 921 | ||
908 | /* end of gnunet-service-zonemaster.c */ | 922 | /* end of gnunet-service-zonemaster.c */ |