From bfa96bbe8cc79655a3e5611d1bbcaf47ccae6f2a Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Fri, 28 Mar 2014 15:09:29 +0000 Subject: [PATCH] cancel delayed disconnect task on free --- .../gnunet-service-transport_neighbours.c | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 2b3d96a55..ac4a44658 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -342,6 +342,11 @@ struct NeighbourMapEntry */ GNUNET_SCHEDULER_TaskIdentifier task; + /** + * Task to disconnect neighbour after we received a DISCONNECT message + */ + GNUNET_SCHEDULER_TaskIdentifier delayed_disconnect_task; + /** * At what time should we sent the next keep-alive message? */ @@ -946,6 +951,13 @@ free_neighbour (struct NeighbourMapEntry *n, n->suggest_handle = NULL; } + /* Cancel the disconnect task */ + if (GNUNET_SCHEDULER_NO_TASK != n->delayed_disconnect_task) + { + GNUNET_SCHEDULER_cancel (n->delayed_disconnect_task); + n->delayed_disconnect_task = GNUNET_SCHEDULER_NO_TASK; + } + /* Cancel the master task */ if (GNUNET_SCHEDULER_NO_TASK != n->task) { @@ -3479,11 +3491,8 @@ void delayed_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc) { struct NeighbourMapEntry *n = cls; - if (GNUNET_YES == test_connected (n)) - GNUNET_STATISTICS_update (GST_stats, - gettext_noop - ("# other peer asked to disconnect from us"), 1, - GNUNET_NO); + + n->delayed_disconnect_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Disconnecting by request from peer %s\n", GNUNET_i2s (&n->id)); @@ -3561,7 +3570,7 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer GNUNET_break_op (0); return; } - GNUNET_SCHEDULER_add_now (&delayed_disconnect, n); + n->delayed_disconnect_task = GNUNET_SCHEDULER_add_now (&delayed_disconnect, n); } -- 2.25.1