From 5fca9ab6b695a5fdbf08262236791809f9b8b91a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 19 Mar 2010 13:55:30 +0000 Subject: [PATCH] bi-di, no multicast PONG if reliable channel exists --- src/transport/gnunet-service-transport.c | 40 +++++++++++++++++++++--- src/transport/plugin_transport_tcp.c | 1 + 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 7c66011e3..7db99c006 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -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) { diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 72c99b3ea..62c13ea64 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -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); } -- 2.25.1