diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-10-07 12:52:19 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-10-07 12:52:19 +0000 |
commit | 5f0ced15a7ac2363341fc5657f93f5932bda2719 (patch) | |
tree | 5004f8af6e1092b9709c842c99b0b841033ca3f8 /src | |
parent | fd42b2cdfa936dc8dd0a5148f7fea2c15575b64c (diff) | |
download | gnunet-5f0ced15a7ac2363341fc5657f93f5932bda2719.tar.gz gnunet-5f0ced15a7ac2363341fc5657f93f5932bda2719.zip |
entry lifetime tracking
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/gnunet-service-fs.c | 220 |
1 files changed, 159 insertions, 61 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 7c78dd21c..c2baf1ada 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -24,9 +24,6 @@ | |||
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | 25 | * |
26 | * TODO: | 26 | * TODO: |
27 | * - track per-peer request latency (using new load API) | ||
28 | * - consider more precise latency estimation (per-peer & request) -- again load API? | ||
29 | * - implement test_load_too_high, make decision priority-based, implement forwarding, etc. | ||
30 | * - introduce random latency in processing | 27 | * - introduce random latency in processing |
31 | * - more statistics | 28 | * - more statistics |
32 | */ | 29 | */ |
@@ -594,12 +591,17 @@ struct PendingRequest | |||
594 | /** | 591 | /** |
595 | * Remove this request after transmission of the current response. | 592 | * Remove this request after transmission of the current response. |
596 | */ | 593 | */ |
597 | int16_t do_remove; | 594 | int8_t do_remove; |
598 | 595 | ||
599 | /** | 596 | /** |
600 | * GNUNET_YES if we should not forward this request to other peers. | 597 | * GNUNET_YES if we should not forward this request to other peers. |
601 | */ | 598 | */ |
602 | int16_t local_only; | 599 | int8_t local_only; |
600 | |||
601 | /** | ||
602 | * GNUNET_YES if we should not forward this request to other peers. | ||
603 | */ | ||
604 | int8_t forward_only; | ||
603 | 605 | ||
604 | }; | 606 | }; |
605 | 607 | ||
@@ -808,6 +810,10 @@ static struct GNUNET_LOAD_Value *datastore_get_load; | |||
808 | */ | 810 | */ |
809 | static struct GNUNET_LOAD_Value *datastore_put_load; | 811 | static struct GNUNET_LOAD_Value *datastore_put_load; |
810 | 812 | ||
813 | /** | ||
814 | * How long do requests typically stay in the routing table? | ||
815 | */ | ||
816 | static struct GNUNET_LOAD_Value *rt_entry_lifetime; | ||
811 | 817 | ||
812 | /** | 818 | /** |
813 | * We've just now completed a datastore request. Update our | 819 | * We've just now completed a datastore request. Update our |
@@ -1378,12 +1384,14 @@ destroy_pending_request (struct PendingRequest *pr) | |||
1378 | -1, | 1384 | -1, |
1379 | GNUNET_NO); | 1385 | GNUNET_NO); |
1380 | } | 1386 | } |
1381 | /* might have already been removed from map in 'process_reply' (if | 1387 | if (GNUNET_YES == |
1382 | there was a unique reply) or never inserted if it was a | 1388 | GNUNET_CONTAINER_multihashmap_remove (query_request_map, |
1383 | duplicate; hence ignore the return value here */ | 1389 | &pr->query, |
1384 | (void) GNUNET_CONTAINER_multihashmap_remove (query_request_map, | 1390 | pr)) |
1385 | &pr->query, | 1391 | { |
1386 | pr); | 1392 | GNUNET_LOAD_update (rt_entry_lifetime, |
1393 | GNUNET_TIME_absolute_get_duration (pr->start_time).value); | ||
1394 | } | ||
1387 | if (pr->qe != NULL) | 1395 | if (pr->qe != NULL) |
1388 | { | 1396 | { |
1389 | GNUNET_DATASTORE_cancel (pr->qe); | 1397 | GNUNET_DATASTORE_cancel (pr->qe); |
@@ -1843,6 +1851,8 @@ shutdown_task (void *cls, | |||
1843 | GNUNET_break (0 == GNUNET_CONTAINER_multihashmap_size (query_request_map)); | 1851 | GNUNET_break (0 == GNUNET_CONTAINER_multihashmap_size (query_request_map)); |
1844 | GNUNET_CONTAINER_multihashmap_destroy (query_request_map); | 1852 | GNUNET_CONTAINER_multihashmap_destroy (query_request_map); |
1845 | query_request_map = NULL; | 1853 | query_request_map = NULL; |
1854 | GNUNET_LOAD_value_free (rt_entry_lifetime); | ||
1855 | rt_entry_lifetime = NULL; | ||
1846 | GNUNET_break (0 == GNUNET_CONTAINER_multihashmap_size (peer_request_map)); | 1856 | GNUNET_break (0 == GNUNET_CONTAINER_multihashmap_size (peer_request_map)); |
1847 | GNUNET_CONTAINER_multihashmap_destroy (peer_request_map); | 1857 | GNUNET_CONTAINER_multihashmap_destroy (peer_request_map); |
1848 | peer_request_map = NULL; | 1858 | peer_request_map = NULL; |
@@ -2078,16 +2088,69 @@ add_to_pending_messages_for_peer (struct ConnectedPeer *cp, | |||
2078 | 2088 | ||
2079 | 2089 | ||
2080 | /** | 2090 | /** |
2081 | * Test if the load on this peer is too high | 2091 | * Test if the DATABASE (GET) load on this peer is too high |
2082 | * to even consider processing the query at | 2092 | * to even consider processing the query at |
2083 | * all. | 2093 | * all. |
2084 | * | 2094 | * |
2085 | * @return GNUNET_YES if the load is too high to do anything, GNUNET_NO to forward (load high, but not too high), GNUNET_SYSERR to indirect (load low) | 2095 | * @return GNUNET_YES if the load is too high to do anything (load high) |
2096 | * GNUNET_NO to process normally (load normal) | ||
2097 | * GNUNET_SYSERR to process for free (load low) | ||
2086 | */ | 2098 | */ |
2087 | static int | 2099 | static int |
2088 | test_load_too_high () | 2100 | test_get_load_too_high (uint32_t priority) |
2089 | { | 2101 | { |
2090 | return GNUNET_SYSERR; // FIXME | 2102 | double ld; |
2103 | |||
2104 | ld = GNUNET_LOAD_get_load (datastore_get_load); | ||
2105 | if (ld < 1) | ||
2106 | { | ||
2107 | GNUNET_STATISTICS_update (stats, | ||
2108 | gettext_noop ("# requests done for free (low load)"), | ||
2109 | 1, | ||
2110 | GNUNET_NO); | ||
2111 | return GNUNET_SYSERR; | ||
2112 | } | ||
2113 | if (ld <= priority) | ||
2114 | { | ||
2115 | GNUNET_STATISTICS_update (stats, | ||
2116 | gettext_noop ("# requests done for a price (normal load)"), | ||
2117 | 1, | ||
2118 | GNUNET_NO); | ||
2119 | return GNUNET_NO; | ||
2120 | } | ||
2121 | GNUNET_STATISTICS_update (stats, | ||
2122 | gettext_noop ("# requests dropped due to high load"), | ||
2123 | 1, | ||
2124 | GNUNET_NO); | ||
2125 | return GNUNET_YES; | ||
2126 | } | ||
2127 | |||
2128 | |||
2129 | |||
2130 | |||
2131 | /** | ||
2132 | * Test if the DATABASE (PUT) load on this peer is too high | ||
2133 | * to even consider processing the query at | ||
2134 | * all. | ||
2135 | * | ||
2136 | * @return GNUNET_YES if the load is too high to do anything (load high) | ||
2137 | * GNUNET_NO to process normally (load normal or low) | ||
2138 | */ | ||
2139 | static int | ||
2140 | test_put_load_too_high (uint32_t priority) | ||
2141 | { | ||
2142 | double ld; | ||
2143 | |||
2144 | if (GNUNET_LOAD_get_average (datastore_put_load) < 50) | ||
2145 | return GNUNET_NO; /* very fast */ | ||
2146 | ld = GNUNET_LOAD_get_load (datastore_put_load); | ||
2147 | if ( (ld < 1) || (ld < priority) ) | ||
2148 | return GNUNET_NO; | ||
2149 | GNUNET_STATISTICS_update (stats, | ||
2150 | gettext_noop ("# storage requests dropped due to high load"), | ||
2151 | 1, | ||
2152 | GNUNET_NO); | ||
2153 | return GNUNET_YES; | ||
2091 | } | 2154 | } |
2092 | 2155 | ||
2093 | 2156 | ||
@@ -2329,8 +2392,6 @@ target_reservation_cb (void *cls, | |||
2329 | pr); | 2392 | pr); |
2330 | return; /* this target round failed */ | 2393 | return; /* this target round failed */ |
2331 | } | 2394 | } |
2332 | /* FIXME: if we are "quite" busy, we may still want to skip | ||
2333 | this round; need more load detection code! */ | ||
2334 | no_route = GNUNET_YES; | 2395 | no_route = GNUNET_YES; |
2335 | } | 2396 | } |
2336 | 2397 | ||
@@ -2486,7 +2547,7 @@ target_peer_select_cb (void *cls, | |||
2486 | P2P_SUCCESS_LIST_SIZE); | 2547 | P2P_SUCCESS_LIST_SIZE); |
2487 | for (i=0;i<P2P_SUCCESS_LIST_SIZE;i++) | 2548 | for (i=0;i<P2P_SUCCESS_LIST_SIZE;i++) |
2488 | if (cp->last_p2p_replies[i] == pr->cp->pid) | 2549 | if (cp->last_p2p_replies[i] == pr->cp->pid) |
2489 | score += 1; /* likely successful based on hot path */ | 2550 | score += 1.0; /* likely successful based on hot path */ |
2490 | } | 2551 | } |
2491 | else | 2552 | else |
2492 | { | 2553 | { |
@@ -2494,14 +2555,14 @@ target_peer_select_cb (void *cls, | |||
2494 | CS2P_SUCCESS_LIST_SIZE); | 2555 | CS2P_SUCCESS_LIST_SIZE); |
2495 | for (i=0;i<CS2P_SUCCESS_LIST_SIZE;i++) | 2556 | for (i=0;i<CS2P_SUCCESS_LIST_SIZE;i++) |
2496 | if (cp->last_client_replies[i] == pr->client_request_list->client_list->client) | 2557 | if (cp->last_client_replies[i] == pr->client_request_list->client_list->client) |
2497 | score += 1; /* likely successful based on hot path */ | 2558 | score += 1.0; /* likely successful based on hot path */ |
2498 | } | 2559 | } |
2499 | /* 3b) include latency */ | 2560 | /* 3b) include latency */ |
2500 | if (cp->avg_delay.value < 4 * TTL_DECREMENT) | 2561 | if (cp->avg_delay.value < 4 * TTL_DECREMENT) |
2501 | score += 1; /* likely fast based on latency */ | 2562 | score += 1.0; /* likely fast based on latency */ |
2502 | /* 3c) include priorities */ | 2563 | /* 3c) include priorities */ |
2503 | if (cp->avg_priority <= pr->remaining_priority / 2.0) | 2564 | if (cp->avg_priority <= pr->remaining_priority / 2.0) |
2504 | score += 1; /* likely successful based on priorities */ | 2565 | score += 1.0; /* likely successful based on priorities */ |
2505 | /* 3d) penalize for queue size */ | 2566 | /* 3d) penalize for queue size */ |
2506 | score -= (2.0 * cp->pending_requests / (double) MAX_QUEUE_PER_PEER); | 2567 | score -= (2.0 * cp->pending_requests / (double) MAX_QUEUE_PER_PEER); |
2507 | /* 3e) include peer proximity */ | 2568 | /* 3e) include peer proximity */ |
@@ -2616,6 +2677,7 @@ forward_request_task (void *cls, | |||
2616 | return; /* configured to not do P2P search */ | 2677 | return; /* configured to not do P2P search */ |
2617 | /* (0) try DHT */ | 2678 | /* (0) try DHT */ |
2618 | if ( (0 == pr->anonymity_level) && | 2679 | if ( (0 == pr->anonymity_level) && |
2680 | (GNUNET_YES != pr->forward_only) && | ||
2619 | (pr->type != GNUNET_BLOCK_TYPE_FS_DBLOCK) && | 2681 | (pr->type != GNUNET_BLOCK_TYPE_FS_DBLOCK) && |
2620 | (pr->type != GNUNET_BLOCK_TYPE_FS_IBLOCK) ) | 2682 | (pr->type != GNUNET_BLOCK_TYPE_FS_IBLOCK) ) |
2621 | { | 2683 | { |
@@ -2677,18 +2739,28 @@ forward_request_task (void *cls, | |||
2677 | } | 2739 | } |
2678 | 2740 | ||
2679 | /* (3) reserve reply bandwidth */ | 2741 | /* (3) reserve reply bandwidth */ |
2680 | cp = GNUNET_CONTAINER_multihashmap_get (connected_peers, | 2742 | if (GNUNET_NO == pr->forward_only) |
2681 | &psc.target.hashPubKey); | 2743 | { |
2682 | GNUNET_assert (NULL != cp); | 2744 | cp = GNUNET_CONTAINER_multihashmap_get (connected_peers, |
2683 | pr->irc = GNUNET_CORE_peer_change_preference (sched, cfg, | 2745 | &psc.target.hashPubKey); |
2684 | &psc.target, | 2746 | GNUNET_assert (NULL != cp); |
2685 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 2747 | pr->irc = GNUNET_CORE_peer_change_preference (sched, cfg, |
2686 | GNUNET_BANDWIDTH_value_init (UINT32_MAX), | 2748 | &psc.target, |
2687 | DBLOCK_SIZE * 2, | 2749 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
2688 | cp->inc_preference, | 2750 | GNUNET_BANDWIDTH_value_init (UINT32_MAX), |
2689 | &target_reservation_cb, | 2751 | DBLOCK_SIZE * 2, |
2690 | pr); | 2752 | cp->inc_preference, |
2691 | cp->inc_preference = 0; | 2753 | &target_reservation_cb, |
2754 | pr); | ||
2755 | cp->inc_preference = 0; | ||
2756 | } | ||
2757 | else | ||
2758 | { | ||
2759 | /* force forwarding */ | ||
2760 | static struct GNUNET_BANDWIDTH_Value32NBO zerobw; | ||
2761 | target_reservation_cb (pr, &psc.target, | ||
2762 | zerobw, zerobw, 0, 0.0); | ||
2763 | } | ||
2692 | } | 2764 | } |
2693 | 2765 | ||
2694 | 2766 | ||
@@ -2871,8 +2943,6 @@ process_reply (void *cls, | |||
2871 | GNUNET_NO); | 2943 | GNUNET_NO); |
2872 | if (prq->sender != NULL) | 2944 | if (prq->sender != NULL) |
2873 | { | 2945 | { |
2874 | /* FIXME: should we be more precise here and not use | ||
2875 | "start_time" but a peer-specific time stamp? */ | ||
2876 | cur_delay = GNUNET_TIME_absolute_get_duration (pr->start_time); | 2946 | cur_delay = GNUNET_TIME_absolute_get_duration (pr->start_time); |
2877 | prq->sender->avg_delay.value | 2947 | prq->sender->avg_delay.value |
2878 | = (prq->sender->avg_delay.value * | 2948 | = (prq->sender->avg_delay.value * |
@@ -2936,6 +3006,8 @@ process_reply (void *cls, | |||
2936 | GNUNET_CONTAINER_multihashmap_remove (query_request_map, | 3006 | GNUNET_CONTAINER_multihashmap_remove (query_request_map, |
2937 | key, | 3007 | key, |
2938 | pr)); | 3008 | pr)); |
3009 | GNUNET_LOAD_update (rt_entry_lifetime, | ||
3010 | GNUNET_TIME_absolute_get_duration (pr->start_time).value); | ||
2939 | break; | 3011 | break; |
2940 | case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: | 3012 | case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: |
2941 | GNUNET_STATISTICS_update (stats, | 3013 | GNUNET_STATISTICS_update (stats, |
@@ -3216,8 +3288,9 @@ handle_p2p_put (void *cls, | |||
3216 | prq.sender->inc_preference += CONTENT_BANDWIDTH_VALUE + 1000 * prq.priority; | 3288 | prq.sender->inc_preference += CONTENT_BANDWIDTH_VALUE + 1000 * prq.priority; |
3217 | prq.sender->trust += prq.priority; | 3289 | prq.sender->trust += prq.priority; |
3218 | } | 3290 | } |
3219 | if (GNUNET_YES == active_migration) | 3291 | if ( (GNUNET_YES == active_migration) && |
3220 | { | 3292 | (GNUNET_NO == test_put_load_too_high (prq.priority)) ) |
3293 | { | ||
3221 | #if DEBUG_FS | 3294 | #if DEBUG_FS |
3222 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3223 | "Replicating result for query `%s' with priority %u\n", | 3296 | "Replicating result for query `%s' with priority %u\n", |
@@ -3498,7 +3571,7 @@ process_local_reply (void *cls, | |||
3498 | return; | 3571 | return; |
3499 | } | 3572 | } |
3500 | if ( (pr->client_request_list == NULL) && | 3573 | if ( (pr->client_request_list == NULL) && |
3501 | ( (GNUNET_YES == test_load_too_high()) || | 3574 | ( (GNUNET_YES == test_get_load_too_high (0)) || |
3502 | (pr->results_found > 5 + 2 * pr->priority) ) ) | 3575 | (pr->results_found > 5 + 2 * pr->priority) ) ) |
3503 | { | 3576 | { |
3504 | #if DEBUG_FS > 2 | 3577 | #if DEBUG_FS > 2 |
@@ -3524,7 +3597,7 @@ process_local_reply (void *cls, | |||
3524 | * @param cp the peer making the request | 3597 | * @param cp the peer making the request |
3525 | * @return effective priority | 3598 | * @return effective priority |
3526 | */ | 3599 | */ |
3527 | static uint32_t | 3600 | static int32_t |
3528 | bound_priority (uint32_t prio_in, | 3601 | bound_priority (uint32_t prio_in, |
3529 | struct ConnectedPeer *cp) | 3602 | struct ConnectedPeer *cp) |
3530 | { | 3603 | { |
@@ -3533,7 +3606,7 @@ bound_priority (uint32_t prio_in, | |||
3533 | double rret; | 3606 | double rret; |
3534 | int ld; | 3607 | int ld; |
3535 | 3608 | ||
3536 | ld = test_load_too_high (); | 3609 | ld = test_get_load_too_high (0); |
3537 | if (ld == GNUNET_SYSERR) | 3610 | if (ld == GNUNET_SYSERR) |
3538 | return 0; /* excess resources */ | 3611 | return 0; /* excess resources */ |
3539 | ret = change_host_trust (cp, prio_in); | 3612 | ret = change_host_trust (cp, prio_in); |
@@ -3546,6 +3619,18 @@ bound_priority (uint32_t prio_in, | |||
3546 | current_priorities | 3619 | current_priorities |
3547 | = (current_priorities * (N-1) + rret)/N; | 3620 | = (current_priorities * (N-1) + rret)/N; |
3548 | } | 3621 | } |
3622 | if ( (ld == GNUNET_YES) && (ret > 0) ) | ||
3623 | { | ||
3624 | /* try with charging */ | ||
3625 | ld = test_get_load_too_high (ret); | ||
3626 | } | ||
3627 | if (ld == GNUNET_YES) | ||
3628 | { | ||
3629 | /* undo charge */ | ||
3630 | if (ret != 0) | ||
3631 | change_host_trust (cp, -ret); | ||
3632 | return -1; /* not enough resources */ | ||
3633 | } | ||
3549 | #undef N | 3634 | #undef N |
3550 | return ret; | 3635 | return ret; |
3551 | } | 3636 | } |
@@ -3612,9 +3697,9 @@ handle_p2p_get (void *cls, | |||
3612 | uint32_t bm; | 3697 | uint32_t bm; |
3613 | size_t bfsize; | 3698 | size_t bfsize; |
3614 | uint32_t ttl_decrement; | 3699 | uint32_t ttl_decrement; |
3700 | int32_t priority; | ||
3615 | enum GNUNET_BLOCK_Type type; | 3701 | enum GNUNET_BLOCK_Type type; |
3616 | int have_ns; | 3702 | int have_ns; |
3617 | int ld; | ||
3618 | 3703 | ||
3619 | msize = ntohs(message->size); | 3704 | msize = ntohs(message->size); |
3620 | if (msize < sizeof (struct GetMessage)) | 3705 | if (msize < sizeof (struct GetMessage)) |
@@ -3680,11 +3765,8 @@ handle_p2p_get (void *cls, | |||
3680 | /* note that we can really only check load here since otherwise | 3765 | /* note that we can really only check load here since otherwise |
3681 | peers could find out that we are overloaded by not being | 3766 | peers could find out that we are overloaded by not being |
3682 | disconnected after sending us a malformed query... */ | 3767 | disconnected after sending us a malformed query... */ |
3683 | 3768 | priority = bound_priority (ntohl (gm->priority), cps); | |
3684 | /* FIXME: query priority should play | 3769 | if (priority < 0) |
3685 | a major role here! */ | ||
3686 | ld = test_load_too_high (); | ||
3687 | if (GNUNET_YES == ld) | ||
3688 | { | 3770 | { |
3689 | #if DEBUG_FS | 3771 | #if DEBUG_FS |
3690 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3772 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -3697,9 +3779,6 @@ handle_p2p_get (void *cls, | |||
3697 | GNUNET_NO); | 3779 | GNUNET_NO); |
3698 | return GNUNET_OK; | 3780 | return GNUNET_OK; |
3699 | } | 3781 | } |
3700 | /* FIXME: if ld == GNUNET_NO, forward | ||
3701 | instead of indirecting! */ | ||
3702 | |||
3703 | #if DEBUG_FS | 3782 | #if DEBUG_FS |
3704 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3783 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3705 | "Received request for `%s' of type %u from peer `%4s' with flags %u\n", | 3784 | "Received request for `%s' of type %u from peer `%4s' with flags %u\n", |
@@ -3716,12 +3795,21 @@ handle_p2p_get (void *cls, | |||
3716 | pr->namespace = (GNUNET_HashCode*) &pr[1]; | 3795 | pr->namespace = (GNUNET_HashCode*) &pr[1]; |
3717 | memcpy (&pr[1], &opt[bits++], sizeof (GNUNET_HashCode)); | 3796 | memcpy (&pr[1], &opt[bits++], sizeof (GNUNET_HashCode)); |
3718 | } | 3797 | } |
3798 | if ( (GNUNET_LOAD_get_load (cp->transmission_delay) > 3) || | ||
3799 | (GNUNET_LOAD_get_average (cp->transmission_delay) > | ||
3800 | GNUNET_CONSTANTS_MAX_CORK_DELAY.value * 2 + GNUNET_LOAD_get_average (rt_entry_lifetime)) ) | ||
3801 | { | ||
3802 | /* don't have BW to send to peer, or would likely take longer than we have for it, | ||
3803 | so at best indirect the query */ | ||
3804 | priority = 0; | ||
3805 | pr->forward_only = GNUNET_YES; | ||
3806 | } | ||
3719 | pr->type = type; | 3807 | pr->type = type; |
3720 | pr->mingle = ntohl (gm->filter_mutator); | 3808 | pr->mingle = ntohl (gm->filter_mutator); |
3721 | if (0 != (bm & GET_MESSAGE_BIT_TRANSMIT_TO)) | 3809 | if (0 != (bm & GET_MESSAGE_BIT_TRANSMIT_TO)) |
3722 | pr->target_pid = GNUNET_PEER_intern ((const struct GNUNET_PeerIdentity*) &opt[bits++]); | 3810 | pr->target_pid = GNUNET_PEER_intern ((const struct GNUNET_PeerIdentity*) &opt[bits++]); |
3723 | pr->anonymity_level = 1; | 3811 | pr->anonymity_level = 1; |
3724 | pr->priority = bound_priority (ntohl (gm->priority), cps); | 3812 | pr->priority = (uint32_t) priority; |
3725 | pr->ttl = bound_ttl (ntohl (gm->ttl), pr->priority); | 3813 | pr->ttl = bound_ttl (ntohl (gm->ttl), pr->priority); |
3726 | pr->query = gm->query; | 3814 | pr->query = gm->query; |
3727 | /* decrement ttl (always) */ | 3815 | /* decrement ttl (always) */ |
@@ -3828,22 +3916,29 @@ handle_p2p_get (void *cls, | |||
3828 | type = GNUNET_BLOCK_TYPE_ANY; /* to get on-demand as well */ | 3916 | type = GNUNET_BLOCK_TYPE_ANY; /* to get on-demand as well */ |
3829 | timeout = GNUNET_TIME_relative_multiply (BASIC_DATASTORE_REQUEST_DELAY, | 3917 | timeout = GNUNET_TIME_relative_multiply (BASIC_DATASTORE_REQUEST_DELAY, |
3830 | (pr->priority + 1)); | 3918 | (pr->priority + 1)); |
3831 | pr->qe = GNUNET_DATASTORE_get (dsh, | 3919 | if (GNUNET_YES != pr->forward_only) |
3832 | &gm->query, | 3920 | pr->qe = GNUNET_DATASTORE_get (dsh, |
3833 | type, | 3921 | &gm->query, |
3834 | pr->priority + 1, | 3922 | type, |
3835 | MAX_DATASTORE_QUEUE, | 3923 | pr->priority + 1, |
3836 | timeout, | 3924 | MAX_DATASTORE_QUEUE, |
3837 | &process_local_reply, | 3925 | timeout, |
3838 | pr); | 3926 | &process_local_reply, |
3927 | pr); | ||
3928 | else | ||
3929 | GNUNET_STATISTICS_update (stats, | ||
3930 | gettext_noop ("# requests forwarded due to high load"), | ||
3931 | 1, | ||
3932 | GNUNET_NO); | ||
3839 | 3933 | ||
3840 | /* Are multiple results possible? If so, start processing remotely now! */ | 3934 | /* Are multiple results possible (and did we look locally)? If so, start processing remotely now! */ |
3841 | switch (pr->type) | 3935 | switch (pr->type) |
3842 | { | 3936 | { |
3843 | case GNUNET_BLOCK_TYPE_FS_DBLOCK: | 3937 | case GNUNET_BLOCK_TYPE_FS_DBLOCK: |
3844 | case GNUNET_BLOCK_TYPE_FS_IBLOCK: | 3938 | case GNUNET_BLOCK_TYPE_FS_IBLOCK: |
3845 | /* only one result, wait for datastore */ | 3939 | /* only one result, wait for datastore */ |
3846 | break; | 3940 | if (GNUNET_YES != pr->forward_only) |
3941 | break; | ||
3847 | default: | 3942 | default: |
3848 | if (pr->task == GNUNET_SCHEDULER_NO_TASK) | 3943 | if (pr->task == GNUNET_SCHEDULER_NO_TASK) |
3849 | pr->task = GNUNET_SCHEDULER_add_now (sched, | 3944 | pr->task = GNUNET_SCHEDULER_add_now (sched, |
@@ -4085,6 +4180,7 @@ main_init (struct GNUNET_SCHEDULER_Handle *s, | |||
4085 | } | 4180 | } |
4086 | connected_peers = GNUNET_CONTAINER_multihashmap_create (enc); | 4181 | connected_peers = GNUNET_CONTAINER_multihashmap_create (enc); |
4087 | query_request_map = GNUNET_CONTAINER_multihashmap_create (max_pending_requests); | 4182 | query_request_map = GNUNET_CONTAINER_multihashmap_create (max_pending_requests); |
4183 | rt_entry_lifetime = GNUNET_LOAD_value_init (); | ||
4088 | peer_request_map = GNUNET_CONTAINER_multihashmap_create (enc); | 4184 | peer_request_map = GNUNET_CONTAINER_multihashmap_create (enc); |
4089 | requests_by_expiration_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 4185 | requests_by_expiration_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
4090 | core = GNUNET_CORE_connect (sched, | 4186 | core = GNUNET_CORE_connect (sched, |
@@ -4107,6 +4203,8 @@ main_init (struct GNUNET_SCHEDULER_Handle *s, | |||
4107 | connected_peers = NULL; | 4203 | connected_peers = NULL; |
4108 | GNUNET_CONTAINER_multihashmap_destroy (query_request_map); | 4204 | GNUNET_CONTAINER_multihashmap_destroy (query_request_map); |
4109 | query_request_map = NULL; | 4205 | query_request_map = NULL; |
4206 | GNUNET_LOAD_value_free (rt_entry_lifetime); | ||
4207 | rt_entry_lifetime = NULL; | ||
4110 | GNUNET_CONTAINER_heap_destroy (requests_by_expiration_heap); | 4208 | GNUNET_CONTAINER_heap_destroy (requests_by_expiration_heap); |
4111 | requests_by_expiration_heap = NULL; | 4209 | requests_by_expiration_heap = NULL; |
4112 | GNUNET_CONTAINER_multihashmap_destroy (peer_request_map); | 4210 | GNUNET_CONTAINER_multihashmap_destroy (peer_request_map); |