From 60b54dd576f6d523b7e1c4d9a20910fb8adce409 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Thu, 16 Jan 2014 11:54:05 +0000 Subject: [PATCH] - add explicit shutdown state - don't try to reconnect when destroying last connection during tunnel_destroy - don't create new connections for a tunnel in shutdown --- src/mesh/gnunet-service-mesh_tunnel.c | 8 ++++++++ src/mesh/gnunet-service-mesh_tunnel.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index 7b51106af..110c6d07e 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c @@ -1872,6 +1872,7 @@ GMT_remove_connection (struct MeshTunnel3 *t, /* Start new connections if needed */ if (NULL == t->connection_head && GNUNET_SCHEDULER_NO_TASK == t->destroy_task + && MESH_TUNNEL3_SHUTDOWN != t->cstate && GNUNET_NO == shutting_down) { LOG (GNUNET_ERROR_TYPE_DEBUG, " no more connections, getting new ones\n"); @@ -1996,6 +1997,7 @@ delayed_destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct MeshTunnel3 *t = cls; t->destroy_task = GNUNET_SCHEDULER_NO_TASK; + t->cstate = MESH_TUNNEL3_SHUTDOWN; GMT_destroy (t); } @@ -2127,6 +2129,12 @@ GMT_use_path (struct MeshTunnel3 *t, struct MeshPeerPath *p) return NULL; } + if (MESH_TUNNEL3_SHUTDOWN == t->cstate) + { + GNUNET_break (0); + return NULL; + } + for (own_pos = 0; own_pos < p->length; own_pos++) { if (p->peers[own_pos] == myid) diff --git a/src/mesh/gnunet-service-mesh_tunnel.h b/src/mesh/gnunet-service-mesh_tunnel.h index 3a6f9fdc1..afa12aa6a 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.h +++ b/src/mesh/gnunet-service-mesh_tunnel.h @@ -64,6 +64,11 @@ enum MeshTunnel3CState * Peer connected and ready to accept data. */ MESH_TUNNEL3_READY, + + /** + * Tunnel being shut down, don't try to keep it alive. + */ + MESH_TUNNEL3_SHUTDOWN }; -- 2.25.1