bi-di, no multicast PONG if reliable channel exists
authorChristian Grothoff <christian@grothoff.org>
Fri, 19 Mar 2010 13:55:30 +0000 (13:55 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 19 Mar 2010 13:55:30 +0000 (13:55 +0000)
src/transport/gnunet-service-transport.c
src/transport/plugin_transport_tcp.c

index 7c66011e3d6bd3dc29140fc840228286d35c451a..7db99c0062fabf62912784b876fb3655613be1bf 100644 (file)
@@ -23,9 +23,6 @@
  * @brief low-level P2P messaging
  * @author Christian Grothoff
  *
- * BUGS:
- * - bi-directional nature of TCP is not exploited
- *
  * NOTE:
  * - This code uses 'GNUNET_a2s' for debug printing in many places,
  *   which is technically wrong since it assumes we have IP+Port 
@@ -3003,11 +3000,44 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_CRYPTO_rsa_sign (my_private_key,
                                          &pong->purpose, &pong->signature));
-
   n = find_neighbour(peer);
   if (n == NULL)
     n = setup_new_neighbour(peer);
-  /* broadcast 'PONG' to all available addresses */
+  /* first try reliable response transmission */
+  rl = n->plugins;
+  while (rl != NULL)
+    {
+      fal = rl->addresses;
+      while (fal != NULL)
+       {
+         if (-1 != rl->plugin->api->send (rl->plugin->api->cls,
+                                          peer,
+                                          (const char*) pong,
+                                          ntohs (pong->header.size),
+                                          TRANSPORT_PONG_PRIORITY, 
+                                          HELLO_VERIFICATION_TIMEOUT,
+                                          fal->addr,
+                                          fal->addrlen,
+                                          GNUNET_SYSERR,
+                                          NULL, NULL))
+           {
+             /* done! */
+             GNUNET_STATISTICS_update (stats,
+                                       gettext_noop ("# PONGs unicast via reliable transport"),
+                                       1,
+                                       GNUNET_NO);      
+             GNUNET_free (pong);
+             return GNUNET_OK;
+           }
+         fal = fal->next;
+       }
+      rl = rl->next;
+    }
+  /* no reliable method found, do multicast */
+  GNUNET_STATISTICS_update (stats,
+                           gettext_noop ("# PONGs multicast to all available addresses"),
+                           1,
+                           GNUNET_NO);      
   rl = n->plugins;
   while (rl != NULL)
     {
index 72c99b3ea2bd45621582162e4393d3220ca04410..62c13ea6494212b185f414570b1a48c51429cb4c 100644 (file)
@@ -1110,6 +1110,7 @@ handle_tcp_welcome (void *cls,
       GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
       return;
     }
+  session->last_activity = GNUNET_TIME_absolute_get ();
   session->expecting_welcome = GNUNET_NO;
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }