From 9ffd65f2427a9f553eb5390800c3a6191d0bfb8a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 22 Oct 2011 20:22:59 +0000 Subject: [PATCH] fixing 1836 --- src/transport/gnunet-service-transport.c | 22 ++++++++++++++----- .../gnunet-service-transport_neighbours.c | 9 +++++--- .../gnunet-service-transport_neighbours.h | 4 +++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 602a597e5..bbbb6f78b 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -412,20 +412,30 @@ ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer, GST_neighbours_force_disconnect(peer); return; } - - GST_neighbours_switch_to_address (peer, plugin_name, plugin_addr, - plugin_addr_len, session, ats, ats_count); + if (GNUNET_YES != + GST_neighbours_switch_to_address (peer, plugin_name, plugin_addr, + plugin_addr_len, session, ats, ats_count)) + { +#if DEBUG_TRANSPORT + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Connection is not yet up, ignoring quota for now\n"); +#endif + /* FIXME: maybe we should let ATS know somehow? This is a problem + with the design; ATS may assign bandwidth, but we don't use it; + the current ATS API doesn't give us a good way to sync the + connection status between ATS and TRANSPORT */ + return; + } #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending outbound quota of %u Bps for peer `%s' to all clients\n", - ntohl (bandwidth_out.value__), GNUNET_i2s (peer)); + ntohl (bandwidth_out.value__), GNUNET_i2s (peer)); #endif msg.header.size = htons (sizeof (struct QuotaSetMessage)); msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA); msg.quota = bandwidth_out; msg.peer = (*peer); - GST_clients_broadcast (&msg.header, GNUNET_NO); - + GST_clients_broadcast (&msg.header, GNUNET_NO); #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting inbound quota of %u for peer `%s' to \n", diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 486be2314..55a943e55 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -666,8 +666,10 @@ send_connect_continuation (void *cls, * @param session session to use (or NULL) * @param ats performance data * @param ats_count number of entries in ats (excluding 0-termination) + * @return GNUNET_YES if we are currently connected, GNUNET_NO if the + * connection is not up (yet) */ -void +int GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *address, size_t address_len, struct Session *session, @@ -687,7 +689,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, peer, plugin_name, address, address_len, NULL); - return; + return GNUNET_NO; } was_connected = n->is_connected; n->is_connected = GNUNET_YES; @@ -727,12 +729,13 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, &send_connect_continuation, n); if (GNUNET_YES == was_connected) - return; + return GNUNET_YES; /* First tell clients about connected neighbours...*/ neighbours_connected++; GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, GNUNET_NO); connect_notify_cb (callback_cls, peer, ats, ats_count); + return GNUNET_YES; } diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h index 27f7aae31..09384bafd 100644 --- a/src/transport/gnunet-service-transport_neighbours.h +++ b/src/transport/gnunet-service-transport_neighbours.h @@ -200,8 +200,10 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, * @param session session to use (or NULL) * @param ats performance data * @param ats_count number of entries in ats (excluding 0-termination) + * @return GNUNET_YES if we are currently connected, GNUNET_NO if the + * connection is not up (yet) */ -void +int GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *address, size_t address_len, struct Session *session, -- 2.25.1