prevent loopback routing, add some statistics, faster re-transmit
[oweals/gnunet.git] / src / fs / gnunet-service-fs.c
index f2770df3e59ec1bf5d992aae36aaa8e48314480d..6ea47c2e291bbd33ef729e72d0f9549f10c04e27 100644 (file)
@@ -226,7 +226,7 @@ GSF_test_get_load_too_high_ (uint32_t priority)
 static int
 handle_p2p_put (void *cls, const struct GNUNET_PeerIdentity *other,
                 const struct GNUNET_MessageHeader *message,
-                const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+                const struct GNUNET_ATS_Information *atsi)
 {
   struct GSF_ConnectedPeer *cp;
 
@@ -258,6 +258,15 @@ consider_request_for_forwarding (void *cls,
 {
   struct GSF_PendingRequest *pr = cls;
 
+  if (GNUNET_YES !=
+      GSF_pending_request_test_target_ (pr,
+                                       peer))
+  {
+    GNUNET_STATISTICS_update (GSF_stats,
+                             gettext_noop ("# Loopback routes suppressed"), 1,
+                             GNUNET_NO);
+    return;
+  }
   GSF_plan_add_ (cp, pr);
 }
 
@@ -296,7 +305,7 @@ consider_forwarding (void *cls, struct GSF_PendingRequest *pr,
 static int
 handle_p2p_get (void *cls, const struct GNUNET_PeerIdentity *other,
                 const struct GNUNET_MessageHeader *message,
-                const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+                const struct GNUNET_ATS_Information *atsi)
 {
   struct GSF_PendingRequest *pr;
 
@@ -424,7 +433,18 @@ 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))
+  {
+    GNUNET_STATISTICS_update (GSF_stats,
+                             gettext_noop ("# Loopback routes suppressed"), 1,
+                             GNUNET_NO);
+    return GNUNET_YES;
+  }
   GSF_plan_add_ (cp, pr);
   return GNUNET_YES;
 }
@@ -439,7 +459,7 @@ consider_peer_for_forwarding (void *cls, const GNUNET_HashCode * key,
  */
 static void
 peer_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
-                      const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+                      const struct GNUNET_ATS_Information *atsi)
 {
   struct GSF_ConnectedPeer *cp;
 
@@ -508,7 +528,7 @@ main_init (struct GNUNET_SERVER_Handle *server,
                                   NULL, &peer_init_handler,
                                   &peer_connect_handler,
                                   &GSF_peer_disconnect_handler_,
-                                  &GSF_peer_status_handler_, NULL, GNUNET_NO,
+                                  NULL, GNUNET_NO,
                                   NULL, GNUNET_NO, p2p_handlers);
   if (NULL == GSF_core)
   {