From 550d51f9db6905f0a28113b075020109fe38b6f0 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Fri, 29 Jun 2012 16:43:11 +0000 Subject: [PATCH] fix for mantis 2445 --- .../gnunet-service-transport_neighbours.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 71245d493..1c693fd4a 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -870,6 +870,7 @@ free_neighbour (struct NeighbourMapEntry *n, int keep_sessions) { struct MessageQueue *mq; struct GNUNET_TRANSPORT_PluginFunctions *papi; + struct GNUNET_HELLO_Address *old_address; n->is_active = NULL; /* always free'd by its own continuation! */ @@ -892,6 +893,12 @@ free_neighbour (struct NeighbourMapEntry *n, int keep_sessions) disconnect_notify_cb (callback_cls, &n->id); } + + /* cut transport-level connection */ + old_address = GNUNET_HELLO_address_copy(n->primary_address.address); + free_address (&n->primary_address); + free_address (&n->alternative_address); + /* FIXME-PLUGIN-API: This does not seem to guarantee that all transport sessions eventually get killed due to inactivity; they MUST have their own timeout logic (but at least TCP doesn't have @@ -901,21 +908,20 @@ free_neighbour (struct NeighbourMapEntry *n, int keep_sessions) API gives us not even the means to selectively kill only one of them! Killing all sessions like this seems to be very, very wrong. */ + if ((GNUNET_NO == keep_sessions) && - (NULL != n->primary_address.address) && - (NULL != (papi = GST_plugins_find (n->primary_address.address->transport_name)))) + (NULL != old_address) && + (NULL != (papi = GST_plugins_find (old_address->transport_name)))) papi->disconnect (papi->cls, &n->id); + GNUNET_free (old_address); + n->state = S_DISCONNECT_FINISHED; GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (neighbours, &n->id.hashPubKey, n)); - /* cut transport-level connection */ - free_address (&n->primary_address); - free_address (&n->alternative_address); - // FIXME-ATS-API: we might want to be more specific about // which states we do this from in the future (ATS should // have given us a 'suggest_address' handle, and if we have -- 2.25.1