- signal shutdown, don't create new connections, fix 3214
authorBart Polot <bart@net.in.tum.de>
Mon, 16 Dec 2013 10:25:08 +0000 (10:25 +0000)
committerBart Polot <bart@net.in.tum.de>
Mon, 16 Dec 2013 10:25:08 +0000 (10:25 +0000)
src/mesh/gnunet-service-mesh.c
src/mesh/gnunet-service-mesh_peer.c
src/mesh/gnunet-service-mesh_tunnel.c

index a31bfd5e23ccb7d64741df7e3491122d210256ca..b4df7cb4812ffd166eaae47abc621a3e464cb3fc 100644 (file)
@@ -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);
index 6c5bbf752c35aca56e97c615a5680a5316bc182d..30c64377f5e584daaedf08ac9488b4471c911ebd 100644 (file)
@@ -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;
 }
 
index f192bb05b5ac49cc6a30c603164bff95c882721c..181395b09bc70557fb22ce42712a3699970a5133 100644 (file)
@@ -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);