do not loop back
authorChristian Grothoff <christian@grothoff.org>
Wed, 19 Oct 2011 13:31:20 +0000 (13:31 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 19 Oct 2011 13:31:20 +0000 (13:31 +0000)
src/fs/gnunet-service-fs.c
src/fs/gnunet-service-fs_pe.c
src/fs/gnunet-service-fs_pr.c
src/fs/gnunet-service-fs_pr.h

index 866860c0a218db50f2dfaedee417ee7047ae3599..bf6984dd672930f188d1a4b18e6d5b0563016f88 100644 (file)
@@ -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;
 }
index 10c522299e5f6b0da057a9fdff9c31302d7d9ca1..dc83c996011e2c29808d9fc97b35454d046ce3d1 100644 (file)
@@ -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;
 }
index 052fd86eae90a037d9be3df67e38f300198d1509..953983d37ace3647ce47405e61a7b48f23f7b8a6 100644 (file)
@@ -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.
  *
index c8ea5b47fae92be84632b7ce6dfbacce6ba42dd9..c8b52398e198034df7d9519498ff53b6a87c5b7a 100644 (file)
@@ -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.
  */