diff options
Diffstat (limited to 'src/fs/gnunet-service-fs_pe.c')
-rw-r--r-- | src/fs/gnunet-service-fs_pe.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c index 5c63e7b66..21f028a2d 100644 --- a/src/fs/gnunet-service-fs_pe.c +++ b/src/fs/gnunet-service-fs_pe.c | |||
@@ -283,11 +283,11 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp) | |||
283 | delay = | 283 | delay = |
284 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 284 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
285 | 8 + (1LL << 24)); | 285 | 8 + (1LL << 24)); |
286 | delay.rel_value = | 286 | delay.rel_value_us = |
287 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 287 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
288 | delay.rel_value + 1); | 288 | delay.rel_value_us + 1); |
289 | /* Add 0.01 to avg_delay to avoid division-by-zero later */ | 289 | /* Add 0.01 to avg_delay to avoid division-by-zero later */ |
290 | avg_delay = (((avg_delay * (N - 1.0)) + delay.rel_value) / N) + 0.01; | 290 | avg_delay = (((avg_delay * (N - 1.0)) + delay.rel_value_us) / N) + 0.01; |
291 | 291 | ||
292 | /* | 292 | /* |
293 | * For the priority, we need to consider a few basic rules: | 293 | * For the priority, we need to consider a few basic rules: |
@@ -312,27 +312,27 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp) | |||
312 | */ | 312 | */ |
313 | rp->priority = | 313 | rp->priority = |
314 | round ((GSF_current_priorities + | 314 | round ((GSF_current_priorities + |
315 | 1.0) * atan (delay.rel_value / avg_delay)) / M_PI_4; | 315 | 1.0) * atan (delay.rel_value_us / avg_delay)) / M_PI_4; |
316 | /* Note: usage of 'round' and 'atan' requires -lm */ | 316 | /* Note: usage of 'round' and 'atan' requires -lm */ |
317 | 317 | ||
318 | if (rp->transmission_counter != 0) | 318 | if (rp->transmission_counter != 0) |
319 | delay.rel_value += TTL_DECREMENT; | 319 | delay.rel_value_us += TTL_DECREMENT * 1000; |
320 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 320 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
321 | "Considering (re)transmission number %u in %llu ms\n", | 321 | "Considering (re)transmission number %u in %s\n", |
322 | (unsigned int) rp->transmission_counter, | 322 | (unsigned int) rp->transmission_counter, |
323 | (unsigned long long) delay.rel_value); | 323 | GNUNET_STRINGS_relative_time_to_string (delay, |
324 | GNUNET_YES)); | ||
324 | rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay); | 325 | rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay); |
325 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 326 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
326 | "Earliest (re)transmission for `%s' in %us\n", | 327 | "Earliest (re)transmission for `%s' in %us\n", |
327 | GNUNET_h2s (&prd->query), rp->transmission_counter); | 328 | GNUNET_h2s (&prd->query), rp->transmission_counter); |
328 | GNUNET_assert (rp->hn == NULL); | 329 | GNUNET_assert (rp->hn == NULL); |
329 | if (GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission).rel_value | 330 | if (0 == GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission).rel_value_us) |
330 | == 0) | ||
331 | rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority); | 331 | rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority); |
332 | else | 332 | else |
333 | rp->hn = | 333 | rp->hn = |
334 | GNUNET_CONTAINER_heap_insert (pp->delay_heap, rp, | 334 | GNUNET_CONTAINER_heap_insert (pp->delay_heap, rp, |
335 | rp->earliest_transmission.abs_value); | 335 | rp->earliest_transmission.abs_value_us); |
336 | GNUNET_assert (GNUNET_YES == | 336 | GNUNET_assert (GNUNET_YES == |
337 | GNUNET_CONTAINER_multihashmap_contains_value (pp->plan_map, | 337 | GNUNET_CONTAINER_multihashmap_contains_value (pp->plan_map, |
338 | get_rp_key (rp), | 338 | get_rp_key (rp), |
@@ -363,8 +363,8 @@ get_latest (const struct GSF_RequestPlan *rp) | |||
363 | bi = bi->next_PE; | 363 | bi = bi->next_PE; |
364 | while (NULL != bi) | 364 | while (NULL != bi) |
365 | { | 365 | { |
366 | if (GSF_pending_request_get_data_ (bi->pr)->ttl.abs_value > | 366 | if (GSF_pending_request_get_data_ (bi->pr)->ttl.abs_value_us > |
367 | GSF_pending_request_get_data_ (ret)->ttl.abs_value) | 367 | GSF_pending_request_get_data_ (ret)->ttl.abs_value_us) |
368 | ret = bi->pr; | 368 | ret = bi->pr; |
369 | bi = bi->next_PE; | 369 | bi = bi->next_PE; |
370 | } | 370 | } |
@@ -459,8 +459,8 @@ schedule_peer_transmission (void *cls, | |||
459 | } | 459 | } |
460 | /* move ready requests to priority queue */ | 460 | /* move ready requests to priority queue */ |
461 | while ((NULL != (rp = GNUNET_CONTAINER_heap_peek (pp->delay_heap))) && | 461 | while ((NULL != (rp = GNUNET_CONTAINER_heap_peek (pp->delay_heap))) && |
462 | (GNUNET_TIME_absolute_get_remaining | 462 | (0 == GNUNET_TIME_absolute_get_remaining |
463 | (rp->earliest_transmission).rel_value == 0)) | 463 | (rp->earliest_transmission).rel_value_us)) |
464 | { | 464 | { |
465 | GNUNET_assert (rp == GNUNET_CONTAINER_heap_remove_root (pp->delay_heap)); | 465 | GNUNET_assert (rp == GNUNET_CONTAINER_heap_remove_root (pp->delay_heap)); |
466 | rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority); | 466 | rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority); |
@@ -477,10 +477,12 @@ schedule_peer_transmission (void *cls, | |||
477 | } | 477 | } |
478 | delay = GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission); | 478 | delay = GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission); |
479 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 479 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
480 | "Sleeping for %llu ms before retrying requests on plan %p.\n", | 480 | "Sleeping for %s before retrying requests on plan %p.\n", |
481 | (unsigned long long) delay.rel_value, pp); | 481 | GNUNET_STRINGS_relative_time_to_string (delay, |
482 | GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# delay heap timeout"), | 482 | GNUNET_YES), |
483 | delay.rel_value, GNUNET_NO); | 483 | pp); |
484 | GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# delay heap timeout (ms)"), | ||
485 | delay.rel_value_us / 1000LL, GNUNET_NO); | ||
484 | 486 | ||
485 | pp->task = | 487 | pp->task = |
486 | GNUNET_SCHEDULER_add_delayed (delay, &schedule_peer_transmission, pp); | 488 | GNUNET_SCHEDULER_add_delayed (delay, &schedule_peer_transmission, pp); |
@@ -551,8 +553,8 @@ merge_pr (void *cls, const struct GNUNET_HashCode * query, void *element) | |||
551 | GNUNET_NO); | 553 | GNUNET_NO); |
552 | #endif | 554 | #endif |
553 | latest = get_latest (rp); | 555 | latest = get_latest (rp); |
554 | if (GSF_pending_request_get_data_ (latest)->ttl.abs_value < | 556 | if (GSF_pending_request_get_data_ (latest)->ttl.abs_value_us < |
555 | prd->ttl.abs_value) | 557 | prd->ttl.abs_value_us) |
556 | { | 558 | { |
557 | #if INSANE_STATISTICS | 559 | #if INSANE_STATISTICS |
558 | GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# requests refreshed"), | 560 | GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# requests refreshed"), |
@@ -721,7 +723,7 @@ GSF_request_plan_reference_get_last_transmission_ ( | |||
721 | { | 723 | { |
722 | if (bi->rp->pp->cp == sender) | 724 | if (bi->rp->pp->cp == sender) |
723 | { | 725 | { |
724 | if (0 == bi->rp->last_transmission.abs_value) | 726 | if (0 == bi->rp->last_transmission.abs_value_us) |
725 | *result = GNUNET_TIME_UNIT_FOREVER_ABS; | 727 | *result = GNUNET_TIME_UNIT_FOREVER_ABS; |
726 | else | 728 | else |
727 | *result = bi->rp->last_transmission; | 729 | *result = bi->rp->last_transmission; |