fix shutdown sequence
authorChristian Grothoff <christian@grothoff.org>
Sun, 29 Jan 2017 19:20:48 +0000 (20:20 +0100)
committerChristian Grothoff <christian@grothoff.org>
Sun, 29 Jan 2017 19:20:48 +0000 (20:20 +0100)
src/cadet/cadet.conf.in
src/cadet/gnunet-service-cadet-new_connection.c
src/cadet/gnunet-service-cadet-new_paths.c
src/cadet/gnunet-service-cadet-new_tunnels.c

index 86ba2e535d0a2b6e839c2ccd52a8a4b027822930..296a648e28db224fbb50e33d551de3d5055662ce 100644 (file)
@@ -4,7 +4,7 @@ AUTOSTART = @AUTOSTART@
 @JAVAPORT@PORT = 2096
 HOSTNAME = localhost
 BINARY = gnunet-service-cadet-new
-PREFIX = valgrind --leak-check=yes
+PREFIX = valgrind --leak-check=yes
 ACCEPT_FROM = 127.0.0.1;
 ACCEPT_FROM6 = ::1;
 UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-cadet.sock
index f3603a694c7622b8f1c5ab9d4b97c6bfd406c3e8..688cb1f80c1d00911b439b00204635f7bf4e5f6b 100644 (file)
@@ -225,6 +225,10 @@ GCC_destroy (struct CadetConnection *cc)
   GCPP_del_connection (cc->path,
                        cc->off,
                        cc);
+  for (unsigned int i=0;i<cc->off;i++)
+    GCP_remove_connection (GCPP_get_peer_at_offset (cc->path,
+                                                    i),
+                           cc);
   GNUNET_assert (GNUNET_YES ==
                  GNUNET_CONTAINER_multishortmap_remove (connections,
                                                         &GCC_get_id (cc)->connection_of_tunnel,
index 28df5e1592eb28523ddd0a3a8f8d64f64a9a009b..05d702717f4dc218299d09647423e71bebf38e44 100644 (file)
@@ -28,6 +28,7 @@
  */
 #include "platform.h"
 #include "gnunet-service-cadet-new_connection.h"
+#include "gnunet-service-cadet-new_tunnels.h"
 #include "gnunet-service-cadet-new_peer.h"
 #include "gnunet-service-cadet-new_paths.h"
 
@@ -191,7 +192,20 @@ path_destroy (struct CadetPeerPath *path)
        "Destroying path %s\n",
        GCPP_2s (path));
   for (unsigned int i=0;i<path->entries_length;i++)
-    GNUNET_free (path->entries[i]);
+  {
+    struct CadetPeerPathEntry *entry = path->entries[i];
+
+    if (NULL != entry->cc)
+    {
+      struct CadetTConnection *ct;
+
+      ct = GCC_get_ct (entry->cc);
+      if (NULL != ct)
+        GCT_connection_lost (ct);
+      GCC_destroy_without_tunnel (entry->cc);
+    }
+    GNUNET_free (entry);
+  }
   GNUNET_free (path->entries);
   GNUNET_free (path);
 }
index e41164220c3ba718a84f311dfa740f5ec4ba90d2..1afd75bb280e99175aa43b0ea693a43e3c9c79a8 100644 (file)
@@ -2037,6 +2037,7 @@ destroy_tunnel (void *cls)
     GNUNET_free (t->unverified_ax);
   }
   cleanup_ax (&t->ax);
+  GNUNET_assert (NULL == t->destroy_task);
   GNUNET_free (t);
 }
 
@@ -2061,12 +2062,14 @@ GCT_remove_channel (struct CadetTunnel *t,
                  GNUNET_CONTAINER_multihashmap32_remove (t->channels,
                                                          ntohl (ctn.cn),
                                                          ch));
-  if (0 ==
-      GCT_count_channels (t))
+  if ( (0 ==
+        GCT_count_channels (t)) &&
+       (NULL == t->destroy_task) )
   {
-    t->destroy_task = GNUNET_SCHEDULER_add_delayed (IDLE_DESTROY_DELAY,
-                                                    &destroy_tunnel,
-                                                    t);
+    t->destroy_task
+      = GNUNET_SCHEDULER_add_delayed (IDLE_DESTROY_DELAY,
+                                      &destroy_tunnel,
+                                      t);
   }
 }