- fix peer to notify
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh.c
index 214fc90fc288b8f51301d44b79cbfd67955263e9..10b65aa5d6b5ea9bdb60618c5a6759b840283866 100644 (file)
@@ -52,6 +52,7 @@
 #include "gnunet-service-mesh_tunnel.h"
 #include "gnunet-service-mesh_dht.h"
 #include "gnunet-service-mesh_peer.h"
+#include "gnunet-service-mesh_hello.h"
 
 
 /******************************************************************************/
@@ -75,6 +76,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,12 +105,17 @@ 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 ();
+  GMH_shutdown ();
   GMD_shutdown ();
-  GMP_shutdown ();
   GMC_shutdown ();
   GMT_shutdown ();
+  GMP_shutdown ();
 
+  GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
+  stats = NULL;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "shut down\n");
 }
 
@@ -132,10 +144,11 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
   GNUNET_CRYPTO_eddsa_key_get_public (my_private_key, &my_full_id.public_key);
   myid = GNUNET_PEER_intern (&my_full_id);
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Mesh for peer [%s] starting\n",
+              "STARTING SERVICE (MESH) for peer [%s]\n",
               GNUNET_i2s (&my_full_id));
 
   GML_init (server);    /* Local clients */
+  GMH_init (c);         /* Hellos */
   GMC_init (c);         /* Connections */
   GMP_init (c);         /* Peers */
   GMD_init (c);         /* DHT */
@@ -158,6 +171,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);