From a6d5893f9680dea995b1172f601adc27b2039b75 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 25 Oct 2015 22:39:09 +0000 Subject: [PATCH] -fix indentation, fix bug that caused us to try to merge requests twice --- src/fs/gnunet-service-fs.c | 14 +++++---- src/fs/gnunet-service-fs_cp.c | 6 ++-- src/fs/gnunet-service-fs_pe.c | 54 +++++++++++++++++++++++------------ src/fs/gnunet-service-fs_pe.h | 3 +- 4 files changed, 51 insertions(+), 26 deletions(-) diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 11cbe5a70..a4300a4ce 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c @@ -575,7 +575,7 @@ shutdown_task (void *cls, * peer connects, giving us a chance to decide about submitting * the existing request to the new peer. * - * @param cls the 'struct GSF_ConnectedPeer' of the new peer + * @param cls the `struct GSF_ConnectedPeer` of the new peer * @param key query for the request * @param pr handle to the pending request * @return #GNUNET_YES to continue to iterate @@ -589,10 +589,12 @@ consider_peer_for_forwarding (void *cls, struct GNUNET_PeerIdentity pid; GSF_connected_peer_get_identity_ (cp, &pid); - if (GNUNET_YES != GSF_pending_request_test_target_ (pr, &pid)) + if (GNUNET_YES != + GSF_pending_request_test_target_ (pr, &pid)) { GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# Loopback routes suppressed"), 1, + gettext_noop ("# Loopback routes suppressed"), + 1, GNUNET_NO); return GNUNET_YES; } @@ -608,11 +610,13 @@ consider_peer_for_forwarding (void *cls, * @param cp handle to the newly created connected peer record */ static void -connected_peer_cb (void *cls, struct GSF_ConnectedPeer *cp) +connected_peer_cb (void *cls, + struct GSF_ConnectedPeer *cp) { if (NULL == cp) return; - GSF_iterate_pending_requests_ (&consider_peer_for_forwarding, cp); + GSF_iterate_pending_requests_ (&consider_peer_for_forwarding, + cp); } diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 7e5ffb45e..67338b6ec 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c @@ -658,8 +658,10 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, cp->creation_cb = creation_cb; cp->creation_cb_cls = creation_cb_cls; cp->respect_iterate_req = - GNUNET_PEERSTORE_iterate (peerstore, "fs", peer, "respect", - GNUNET_TIME_UNIT_FOREVER_REL, &peer_respect_cb, + GNUNET_PEERSTORE_iterate (peerstore, "fs", + peer, "respect", + GNUNET_TIME_UNIT_FOREVER_REL, + &peer_respect_cb, cp); } diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c index 68c98ae8b..a9cfefcaa 100644 --- a/src/fs/gnunet-service-fs_pe.c +++ b/src/fs/gnunet-service-fs_pe.c @@ -529,7 +529,9 @@ struct MergeContext * #GNUNET_NO if not (merge success) */ static int -merge_pr (void *cls, const struct GNUNET_HashCode * query, void *element) +merge_pr (void *cls, + const struct GNUNET_HashCode *query, + void *element) { struct MergeContext *mpr = cls; struct GSF_RequestPlan *rp = element; @@ -538,18 +540,26 @@ merge_pr (void *cls, const struct GNUNET_HashCode * query, void *element) struct GSF_PendingRequest *latest; if (GNUNET_OK != - GSF_pending_request_is_compatible_ (mpr->pr, rp->pe_head->pr)) + GSF_pending_request_is_compatible_ (mpr->pr, + rp->pe_head->pr)) return GNUNET_YES; /* merge new request with existing request plan */ bi = GNUNET_new (struct GSF_PendingRequestPlanBijection); bi->rp = rp; bi->pr = mpr->pr; prd = GSF_pending_request_get_data_ (mpr->pr); - GNUNET_CONTAINER_MDLL_insert (PR, prd->pr_head, prd->pr_tail, bi); - GNUNET_CONTAINER_MDLL_insert (PE, rp->pe_head, rp->pe_tail, bi); + GNUNET_CONTAINER_MDLL_insert (PR, + prd->pr_head, + prd->pr_tail, + bi); + GNUNET_CONTAINER_MDLL_insert (PE, + rp->pe_head, + rp->pe_tail, + bi); mpr->merged = GNUNET_YES; #if INSANE_STATISTICS - GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# requests merged"), 1, + GNUNET_STATISTICS_update (GSF_stats, + gettext_noop ("# requests merged"), 1, GNUNET_NO); #endif latest = get_latest (rp); @@ -557,7 +567,8 @@ merge_pr (void *cls, const struct GNUNET_HashCode * query, void *element) prd->ttl.abs_value_us) { #if INSANE_STATISTICS - GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# requests refreshed"), + GNUNET_STATISTICS_update (GSF_stats, + gettext_noop ("# requests refreshed"), 1, GNUNET_NO); #endif rp->transmission_counter = 0; /* reset */ @@ -597,38 +608,45 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, pp->cp = cp; GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (plans, - id, pp, + id, + pp, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); } mpc.merged = GNUNET_NO; mpc.pr = pr; GNUNET_CONTAINER_multihashmap_get_multiple (pp->plan_map, &GSF_pending_request_get_data_ - (pr)->query, &merge_pr, &mpc); - if (GNUNET_NO != mpc.merged) - return; - GNUNET_CONTAINER_multihashmap_get_multiple (pp->plan_map, - &GSF_pending_request_get_data_ - (pr)->query, &merge_pr, &mpc); + (pr)->query, + &merge_pr, &mpc); if (GNUNET_NO != mpc.merged) return; plan_count++; - GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# query plan entries"), 1, + GNUNET_STATISTICS_update (GSF_stats, + gettext_noop ("# query plan entries"), + 1, GNUNET_NO); prd = GSF_pending_request_get_data_ (pr); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Planning transmission of query `%s' to peer `%s'\n", - GNUNET_h2s (&prd->query), GNUNET_i2s (id)); + GNUNET_h2s (&prd->query), + GNUNET_i2s (id)); rp = GNUNET_new (struct GSF_RequestPlan); bi = GNUNET_new (struct GSF_PendingRequestPlanBijection); bi->rp = rp; bi->pr = pr; - GNUNET_CONTAINER_MDLL_insert (PR, prd->pr_head, prd->pr_tail, bi); - GNUNET_CONTAINER_MDLL_insert (PE, rp->pe_head, rp->pe_tail, bi); + GNUNET_CONTAINER_MDLL_insert (PR, + prd->pr_head, + prd->pr_tail, + bi); + GNUNET_CONTAINER_MDLL_insert (PE, + rp->pe_head, + rp->pe_tail, + bi); rp->pp = pp; GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_put (pp->plan_map, - get_rp_key (rp), rp, + get_rp_key (rp), + rp, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); plan (pp, rp); } diff --git a/src/fs/gnunet-service-fs_pe.h b/src/fs/gnunet-service-fs_pe.h index a6c011415..a9c3c5c4e 100644 --- a/src/fs/gnunet-service-fs_pe.h +++ b/src/fs/gnunet-service-fs_pe.h @@ -36,7 +36,8 @@ * @param pr request with the entry */ void -GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr); +GSF_plan_add_ (struct GSF_ConnectedPeer *cp, + struct GSF_PendingRequest *pr); /** -- 2.25.1