diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/fs/gnunet-service-fs_pe.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/fs/gnunet-service-fs_pe.c')
-rw-r--r-- | src/fs/gnunet-service-fs_pe.c | 75 |
1 files changed, 34 insertions, 41 deletions
diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c index d3ab5026b..58fb11cee 100644 --- a/src/fs/gnunet-service-fs_pe.c +++ b/src/fs/gnunet-service-fs_pe.c | |||
@@ -207,9 +207,9 @@ static unsigned long long plan_count; | |||
207 | * @param cls the 'struct GSF_ConnectedPeer' for transmission | 207 | * @param cls the 'struct GSF_ConnectedPeer' for transmission |
208 | * @param tc scheduler context | 208 | * @param tc scheduler context |
209 | */ | 209 | */ |
210 | static void | 210 | static void schedule_peer_transmission (void *cls, |
211 | schedule_peer_transmission (void *cls, | 211 | const struct |
212 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 212 | GNUNET_SCHEDULER_TaskContext *tc); |
213 | 213 | ||
214 | 214 | ||
215 | /** | 215 | /** |
@@ -230,8 +230,9 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp) | |||
230 | prd = GSF_pending_request_get_data_ (rp->prl_head->pr); | 230 | prd = GSF_pending_request_get_data_ (rp->prl_head->pr); |
231 | // FIXME: calculate 'rp->priority'! | 231 | // FIXME: calculate 'rp->priority'! |
232 | if (rp->transmission_counter < 32) | 232 | if (rp->transmission_counter < 32) |
233 | delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 233 | delay = |
234 | 1LL << rp->transmission_counter); | 234 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
235 | 1LL << rp->transmission_counter); | ||
235 | else | 236 | else |
236 | delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, UINT_MAX); | 237 | delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, UINT_MAX); |
237 | rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay); | 238 | rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay); |
@@ -242,13 +243,13 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp) | |||
242 | #endif | 243 | #endif |
243 | 244 | ||
244 | GNUNET_assert (rp->hn == NULL); | 245 | GNUNET_assert (rp->hn == NULL); |
245 | if (GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission).rel_value | 246 | if (GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission). |
246 | == 0) | 247 | rel_value == 0) |
247 | rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority); | 248 | rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority); |
248 | else | 249 | else |
249 | rp->hn = GNUNET_CONTAINER_heap_insert (pp->delay_heap, | 250 | rp->hn = |
250 | rp, | 251 | GNUNET_CONTAINER_heap_insert (pp->delay_heap, rp, |
251 | rp->earliest_transmission.abs_value); | 252 | rp->earliest_transmission.abs_value); |
252 | if (GNUNET_SCHEDULER_NO_TASK != pp->task) | 253 | if (GNUNET_SCHEDULER_NO_TASK != pp->task) |
253 | GNUNET_SCHEDULER_cancel (pp->task); | 254 | GNUNET_SCHEDULER_cancel (pp->task); |
254 | pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp); | 255 | pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp); |
@@ -358,8 +359,8 @@ schedule_peer_transmission (void *cls, | |||
358 | } | 359 | } |
359 | /* move ready requests to priority queue */ | 360 | /* move ready requests to priority queue */ |
360 | while ((NULL != (rp = GNUNET_CONTAINER_heap_peek (pp->delay_heap))) && | 361 | while ((NULL != (rp = GNUNET_CONTAINER_heap_peek (pp->delay_heap))) && |
361 | (GNUNET_TIME_absolute_get_remaining | 362 | (GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission). |
362 | (rp->earliest_transmission).rel_value == 0)) | 363 | rel_value == 0)) |
363 | { | 364 | { |
364 | GNUNET_assert (rp == GNUNET_CONTAINER_heap_remove_root (pp->delay_heap)); | 365 | GNUNET_assert (rp == GNUNET_CONTAINER_heap_remove_root (pp->delay_heap)); |
365 | rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority); | 366 | rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority); |
@@ -371,17 +372,17 @@ schedule_peer_transmission (void *cls, | |||
371 | if (NULL == rp) | 372 | if (NULL == rp) |
372 | { | 373 | { |
373 | #if DEBUG_FS | 374 | #if DEBUG_FS |
374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No active requests for plan %p.\n", |
375 | "No active requests for plan %p.\n", pp); | 376 | pp); |
376 | #endif | 377 | #endif |
377 | return; /* both queues empty */ | 378 | return; /* both queues empty */ |
378 | } | 379 | } |
379 | #if DEBUG_FS | 380 | #if DEBUG_FS |
380 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 381 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
381 | "Sleeping for %llu ms before retrying requests on plan %p.\n", | 382 | "Sleeping for %llu ms before retrying requests on plan %p.\n", |
382 | (unsigned long long) | 383 | (unsigned long long) GNUNET_TIME_absolute_get_remaining (rp-> |
383 | GNUNET_TIME_absolute_get_remaining | 384 | earliest_transmission). |
384 | (rp->earliest_transmission).rel_value, pp); | 385 | rel_value, pp); |
385 | #endif | 386 | #endif |
386 | pp->task = | 387 | pp->task = |
387 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 388 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
@@ -396,11 +397,10 @@ schedule_peer_transmission (void *cls, | |||
396 | #endif | 397 | #endif |
397 | GNUNET_assert (NULL != rp); | 398 | GNUNET_assert (NULL != rp); |
398 | msize = GSF_pending_request_get_message_ (get_latest (rp), 0, NULL); | 399 | msize = GSF_pending_request_get_message_ (get_latest (rp), 0, NULL); |
399 | pp->pth = GSF_peer_transmit_ (pp->cp, | 400 | pp->pth = |
400 | GNUNET_YES, | 401 | GSF_peer_transmit_ (pp->cp, GNUNET_YES, rp->priority, |
401 | rp->priority, | 402 | GNUNET_TIME_UNIT_FOREVER_REL, msize, |
402 | GNUNET_TIME_UNIT_FOREVER_REL, | 403 | &transmit_message_callback, pp); |
403 | msize, &transmit_message_callback, pp); | ||
404 | GNUNET_assert (NULL != pp->pth); | 404 | GNUNET_assert (NULL != pp->pth); |
405 | } | 405 | } |
406 | 406 | ||
@@ -430,9 +430,8 @@ struct MergeContext | |||
430 | * GNUNET_NO if not (merge success) | 430 | * GNUNET_NO if not (merge success) |
431 | */ | 431 | */ |
432 | static int | 432 | static int |
433 | merge_pr (void *cls, | 433 | merge_pr (void *cls, struct GNUNET_CONTAINER_HeapNode *node, void *element, |
434 | struct GNUNET_CONTAINER_HeapNode *node, | 434 | GNUNET_CONTAINER_HeapCostType cost) |
435 | void *element, GNUNET_CONTAINER_HeapCostType cost) | ||
436 | { | 435 | { |
437 | struct MergeContext *mpr = cls; | 436 | struct MergeContext *mpr = cls; |
438 | struct GSF_RequestPlan *rp = element; | 437 | struct GSF_RequestPlan *rp = element; |
@@ -455,14 +454,13 @@ merge_pr (void *cls, | |||
455 | GNUNET_CONTAINER_DLL_insert (prd->rpr_head, prd->rpr_tail, rpr); | 454 | GNUNET_CONTAINER_DLL_insert (prd->rpr_head, prd->rpr_tail, rpr); |
456 | GNUNET_CONTAINER_DLL_insert (rp->prl_head, rp->prl_tail, prl); | 455 | GNUNET_CONTAINER_DLL_insert (rp->prl_head, rp->prl_tail, prl); |
457 | mpr->merged = GNUNET_YES; | 456 | mpr->merged = GNUNET_YES; |
458 | GNUNET_STATISTICS_update (GSF_stats, | 457 | GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# requests merged"), 1, |
459 | gettext_noop ("# requests merged"), 1, GNUNET_NO); | 458 | GNUNET_NO); |
460 | latest = get_latest (rp); | 459 | latest = get_latest (rp); |
461 | if (GSF_pending_request_get_data_ (latest)->ttl.abs_value < | 460 | if (GSF_pending_request_get_data_ (latest)->ttl.abs_value < |
462 | prd->ttl.abs_value) | 461 | prd->ttl.abs_value) |
463 | { | 462 | { |
464 | GNUNET_STATISTICS_update (GSF_stats, | 463 | GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# requests refreshed"), |
465 | gettext_noop ("# requests refreshed"), | ||
466 | 1, GNUNET_NO); | 464 | 1, GNUNET_NO); |
467 | rp->transmission_counter = 0; /* reset */ | 465 | rp->transmission_counter = 0; /* reset */ |
468 | } | 466 | } |
@@ -498,9 +496,7 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr) | |||
498 | pp->delay_heap = | 496 | pp->delay_heap = |
499 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 497 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
500 | pp->cp = cp; | 498 | pp->cp = cp; |
501 | GNUNET_CONTAINER_multihashmap_put (plans, | 499 | GNUNET_CONTAINER_multihashmap_put (plans, &id.hashPubKey, pp, |
502 | &id.hashPubKey, | ||
503 | pp, | ||
504 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 500 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
505 | } | 501 | } |
506 | mpc.merged = GNUNET_NO; | 502 | mpc.merged = GNUNET_NO; |
@@ -512,9 +508,8 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr) | |||
512 | if (mpc.merged != GNUNET_NO) | 508 | if (mpc.merged != GNUNET_NO) |
513 | return; | 509 | return; |
514 | plan_count++; | 510 | plan_count++; |
515 | GNUNET_STATISTICS_update (GSF_stats, | 511 | GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# query plan entries"), 1, |
516 | gettext_noop ("# query plan entries"), | 512 | GNUNET_NO); |
517 | 1, GNUNET_NO); | ||
518 | prd = GSF_pending_request_get_data_ (pr); | 513 | prd = GSF_pending_request_get_data_ (pr); |
519 | #if DEBUG_FS | 514 | #if DEBUG_FS |
520 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 515 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -554,8 +549,8 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp) | |||
554 | if (NULL == pp) | 549 | if (NULL == pp) |
555 | return; /* nothing was ever planned for this peer */ | 550 | return; /* nothing was ever planned for this peer */ |
556 | GNUNET_assert (GNUNET_YES == | 551 | GNUNET_assert (GNUNET_YES == |
557 | GNUNET_CONTAINER_multihashmap_remove (plans, | 552 | GNUNET_CONTAINER_multihashmap_remove (plans, &id.hashPubKey, |
558 | &id.hashPubKey, pp)); | 553 | pp)); |
559 | if (NULL != pp->pth) | 554 | if (NULL != pp->pth) |
560 | GSF_peer_transmit_cancel_ (pp->pth); | 555 | GSF_peer_transmit_cancel_ (pp->pth); |
561 | if (GNUNET_SCHEDULER_NO_TASK != pp->task) | 556 | if (GNUNET_SCHEDULER_NO_TASK != pp->task) |
@@ -588,8 +583,7 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp) | |||
588 | } | 583 | } |
589 | GNUNET_free (rp); | 584 | GNUNET_free (rp); |
590 | } | 585 | } |
591 | GNUNET_STATISTICS_set (GSF_stats, | 586 | GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# query plan entries"), |
592 | gettext_noop ("# query plan entries"), | ||
593 | plan_count, GNUNET_NO); | 587 | plan_count, GNUNET_NO); |
594 | 588 | ||
595 | GNUNET_CONTAINER_heap_destroy (pp->delay_heap); | 589 | GNUNET_CONTAINER_heap_destroy (pp->delay_heap); |
@@ -625,8 +619,7 @@ GSF_plan_notify_request_done_ (struct GSF_PendingRequest *pr) | |||
625 | GNUNET_free (rp); | 619 | GNUNET_free (rp); |
626 | } | 620 | } |
627 | } | 621 | } |
628 | GNUNET_STATISTICS_set (GSF_stats, | 622 | GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# query plan entries"), |
629 | gettext_noop ("# query plan entries"), | ||
630 | plan_count, GNUNET_NO); | 623 | plan_count, GNUNET_NO); |
631 | } | 624 | } |
632 | 625 | ||