From: Christian Grothoff Date: Wed, 19 Oct 2011 13:31:20 +0000 (+0000) Subject: do not loop back X-Git-Tag: initial-import-from-subversion-38251~16399 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cea1f6d7409c705a6b9a26308bae7b5674e0bd6a;p=oweals%2Fgnunet.git do not loop back --- diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 866860c0a..bf6984dd6 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c @@ -424,7 +424,13 @@ consider_peer_for_forwarding (void *cls, const GNUNET_HashCode * key, struct GSF_PendingRequest *pr) { struct GSF_ConnectedPeer *cp = cls; + struct GNUNET_PeerIdentity pid; + GSF_connected_peer_get_identity_ (cp, &pid); + if (GNUNET_YES != + GSF_pending_request_test_target_ (pr, + &pid)) + return GNUNET_YES; GSF_plan_add_ (cp, pr); return GNUNET_YES; } diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c index 10c522299..dc83c9960 100644 --- a/src/fs/gnunet-service-fs_pe.c +++ b/src/fs/gnunet-service-fs_pe.c @@ -334,7 +334,7 @@ transmit_message_callback (void *cls, size_t buf_size, void *buf) plan (pp, rp); GNUNET_STATISTICS_update (GSF_stats, gettext_noop - ("# queries messages sent to other peers"), 1, + ("# query messages sent to other peers"), 1, GNUNET_NO); return msize; } diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index 052fd86ea..953983d37 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c @@ -1336,6 +1336,26 @@ check_error_and_continue: } +/** + * Is the given target a legitimate peer for forwarding the given request? + * + * @param pr request + * @param target + * @return GNUNET_YES if this request could be forwarded to the given peer + */ +int +GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr, + const struct GNUNET_PeerIdentity *target) +{ + struct GNUNET_PeerIdentity pi; + + if (0 == pr->sender_pid) + return GNUNET_YES; + GNUNET_PEER_resolve (pr->sender_pid, &pi); + return (0 == memcmp (&pi, target, sizeof (struct GNUNET_PeerIdentity))) ? GNUNET_NO :GNUNET_YES; +} + + /** * Look up the request in the local datastore. * diff --git a/src/fs/gnunet-service-fs_pr.h b/src/fs/gnunet-service-fs_pr.h index c8ea5b47f..c8b52398e 100644 --- a/src/fs/gnunet-service-fs_pr.h +++ b/src/fs/gnunet-service-fs_pr.h @@ -355,6 +355,19 @@ GSF_local_lookup_ (struct GSF_PendingRequest *pr, GSF_LocalLookupContinuation cont, void *cont_cls); +/** + * Is the given target a legitimate peer for forwarding the given request? + * + * @param pr request + * @param target + * @return GNUNET_YES if this request could be forwarded to the given peer + */ +int +GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr, + const struct GNUNET_PeerIdentity *target); + + + /** * Setup the subsystem. */