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