From f88bca9af603165f559f48a62878658dbd612bc0 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Mon, 16 Dec 2013 10:25:08 +0000 Subject: [PATCH] - signal shutdown, don't create new connections, fix 3214 --- src/mesh/gnunet-service-mesh.c | 9 +++++++++ src/mesh/gnunet-service-mesh_peer.c | 1 + src/mesh/gnunet-service-mesh_tunnel.c | 13 +++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index a31bfd5e2..b4df7cb48 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -75,6 +75,12 @@ GNUNET_PEER_Id myid; */ struct GNUNET_PeerIdentity my_full_id; + +/** + * Signal that shutdown is happening: prevent recover measures. + */ +int shutting_down; + /*************************** Static global variables **************************/ /** @@ -98,6 +104,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "shutting down\n"); + shutting_down = GNUNET_YES; + GML_shutdown (); GMD_shutdown (); GMC_shutdown (); @@ -160,6 +168,7 @@ main (int argc, char *const *argv) int ret; int r; + shutting_down = GNUNET_NO; r = GNUNET_SERVICE_run (argc, argv, "mesh", GNUNET_SERVICE_OPTION_NONE, &run, NULL); GNUNET_free (my_private_key); diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index 6c5bbf752..30c64377f 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c @@ -1695,6 +1695,7 @@ GMP_get_short_id (const struct MeshPeer *peer) struct MeshTunnel3 * GMP_get_tunnel (const struct MeshPeer *peer) { + GNUNET_assert (NULL != peer->tunnel); return peer->tunnel; } diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index f192bb05b..181395b09 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c @@ -221,6 +221,12 @@ extern GNUNET_PEER_Id myid; extern struct GNUNET_PeerIdentity my_full_id; +/** + * Don't try to recover tunnels if shutting down. + */ +extern int shutting_down; + + /** * Set of all tunnels, in order to trigger a new exchange on rekey. * Indexed by peer's ID. @@ -1756,7 +1762,8 @@ GMT_add_connection (struct MeshTunnel3 *t, struct MeshConnection *c) * @param c Connection. */ void -GMT_remove_connection (struct MeshTunnel3 *t, struct MeshConnection *c) +GMT_remove_connection (struct MeshTunnel3 *t, + struct MeshConnection *c) { struct MeshTConnection *aux; struct MeshTConnection *next; @@ -1774,7 +1781,9 @@ GMT_remove_connection (struct MeshTunnel3 *t, struct MeshConnection *c) } /* Start new connections if needed */ - if (NULL == t->connection_head && GNUNET_NO == t->destroy) + if (NULL == t->connection_head + && GNUNET_NO == t->destroy + && GNUNET_NO == shutting_down) { LOG (GNUNET_ERROR_TYPE_DEBUG, " no more connections\n"); GMP_connect (t->peer); -- 2.25.1