From 68857e2f64f7a5ef807babceb0ad68c9cae6067e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 17 Jan 2012 15:37:23 +0000 Subject: [PATCH] -fixing #2069 --- src/vpn/gnunet-service-vpn.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c index 5d91d79f5..0a6eacb14 100644 --- a/src/vpn/gnunet-service-vpn.c +++ b/src/vpn/gnunet-service-vpn.c @@ -227,6 +227,11 @@ struct TunnelState */ struct DestinationEntry destination; + /** + * Task scheduled to destroy the tunnel (or NO_TASK). + */ + GNUNET_SCHEDULER_TaskIdentifier destroy_task; + /** * Addess family used for this tunnel on the local TUN interface. */ @@ -494,6 +499,23 @@ send_client_reply (struct GNUNET_SERVER_Client *client, } +/** + * Destroy the mesh tunnel. + * + * @param cls the 'struct TunnelState' with the tunnel to destroy + * @param ts schedule context + */ +static void +destroy_tunnel_task (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + struct TunnelState *ts = cls; + + ts->destroy_task = GNUNET_SCHEDULER_NO_TASK; + GNUNET_MESH_tunnel_destroy (ts->tunnel); +} + + /** * Method called whenever a peer has disconnected from the tunnel. * @@ -522,7 +544,8 @@ tunnel_peer_disconnect_handler (void *cls, return; /* hope for reconnect eventually */ /* as we are most likely going to change the exit node now, we should just destroy the tunnel entirely... */ - GNUNET_MESH_tunnel_destroy (ts->tunnel); + if (GNUNET_SCHEDULER_NO_TASK == ts->destroy_task) + ts->destroy_task = GNUNET_SCHEDULER_add_now (&destroy_tunnel_task, ts); } @@ -742,6 +765,11 @@ free_tunnel_state (struct TunnelState *ts) GNUNET_STATISTICS_update (stats, gettext_noop ("# Active tunnels"), -1, GNUNET_NO); + if (GNUNET_SCHEDULER_NO_TASK != ts->destroy_task) + { + GNUNET_SCHEDULER_cancel (ts->destroy_task); + ts->destroy_task = GNUNET_SCHEDULER_NO_TASK; + } while (NULL != (tnq = ts->tmq_head)) { GNUNET_CONTAINER_DLL_remove (ts->tmq_head, -- 2.25.1