aboutsummaryrefslogtreecommitdiff
path: root/src/cadet
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-01-22 00:10:26 +0100
committerChristian Grothoff <christian@grothoff.org>2017-01-22 00:10:26 +0100
commite6b80ab7b7de86928aafb7ccfd39a2019f256fd6 (patch)
treea7cc8663473c85b7c5be1fa83cca3a8cd6bf4266 /src/cadet
parentf8f51150a4f28fecd7f0997227c5c15edfe9dd02 (diff)
downloadgnunet-e6b80ab7b7de86928aafb7ccfd39a2019f256fd6.tar.gz
gnunet-e6b80ab7b7de86928aafb7ccfd39a2019f256fd6.zip
ensure tunnels are shutdown at the right time during shutdown
Diffstat (limited to 'src/cadet')
-rw-r--r--src/cadet/cadet.conf.in2
-rw-r--r--src/cadet/gnunet-service-cadet-new.c29
-rw-r--r--src/cadet/gnunet-service-cadet-new_tunnels.c15
-rw-r--r--src/cadet/gnunet-service-cadet-new_tunnels.h9
4 files changed, 53 insertions, 2 deletions
diff --git a/src/cadet/cadet.conf.in b/src/cadet/cadet.conf.in
index 1ee830dbf..88f49fde8 100644
--- a/src/cadet/cadet.conf.in
+++ b/src/cadet/cadet.conf.in
@@ -3,7 +3,7 @@ FORCESTART = YES
3AUTOSTART = @AUTOSTART@ 3AUTOSTART = @AUTOSTART@
4@JAVAPORT@PORT = 2096 4@JAVAPORT@PORT = 2096
5HOSTNAME = localhost 5HOSTNAME = localhost
6BINARY = gnunet-service-cadet-new 6BINARY = gnunet-service-cadet
7ACCEPT_FROM = 127.0.0.1; 7ACCEPT_FROM = 127.0.0.1;
8ACCEPT_FROM6 = ::1; 8ACCEPT_FROM6 = ::1;
9UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-cadet.sock 9UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-cadet.sock
diff --git a/src/cadet/gnunet-service-cadet-new.c b/src/cadet/gnunet-service-cadet-new.c
index 6ba0df69e..ff143b4b3 100644
--- a/src/cadet/gnunet-service-cadet-new.c
+++ b/src/cadet/gnunet-service-cadet-new.c
@@ -311,6 +311,30 @@ GSC_bind (struct CadetClient *c,
311 311
312 312
313/** 313/**
314 * Callback invoked on all peers to destroy all tunnels
315 * that may still exist.
316 *
317 * @param cls NULL
318 * @param pid identify of a peer
319 * @param value a `struct CadetPeer` that may still have a tunnel
320 * @return #GNUNET_OK (iterate over all entries)
321 */
322static int
323destroy_tunnels_now (void *cls,
324 const struct GNUNET_PeerIdentity *pid,
325 void *value)
326{
327 struct CadetPeer *cp = value;
328 struct CadetTunnel *t = GCP_get_tunnel (cp,
329 GNUNET_NO);
330
331 if (NULL != t)
332 GCT_destroy_tunnel_now (t);
333 return GNUNET_OK;
334}
335
336
337/**
314 * Task run during shutdown. 338 * Task run during shutdown.
315 * 339 *
316 * @param cls unused 340 * @param cls unused
@@ -338,7 +362,10 @@ shutdown_task (void *cls)
338 GNUNET_CONTAINER_multihashmap_destroy (loose_channels); 362 GNUNET_CONTAINER_multihashmap_destroy (loose_channels);
339 loose_channels = NULL; 363 loose_channels = NULL;
340 } 364 }
341 /* All channels, connections and CORE must be down before this point. */ 365 /* Destroy tunnels. Note that all channels must be destroyed first! */
366 GCP_iterate_all (&destroy_tunnels_now,
367 NULL);
368 /* All tunnels, channels, connections and CORE must be down before this point. */
342 GCP_destroy_all_peers (); 369 GCP_destroy_all_peers ();
343 if (NULL != peers) 370 if (NULL != peers)
344 { 371 {
diff --git a/src/cadet/gnunet-service-cadet-new_tunnels.c b/src/cadet/gnunet-service-cadet-new_tunnels.c
index 73bbaf042..06c98fcee 100644
--- a/src/cadet/gnunet-service-cadet-new_tunnels.c
+++ b/src/cadet/gnunet-service-cadet-new_tunnels.c
@@ -1559,6 +1559,21 @@ GCT_remove_channel (struct CadetTunnel *t,
1559 1559
1560 1560
1561/** 1561/**
1562 * Destroys the tunnel @a t now, without delay. Used during shutdown.
1563 *
1564 * @param t tunnel to destroy
1565 */
1566void
1567GCT_destroy_tunnel_now (struct CadetTunnel *t)
1568{
1569 GNUNET_assert (0 ==
1570 GNUNET_CONTAINER_multihashmap32_size (t->channels));
1571 GNUNET_SCHEDULER_cancel (t->destroy_task);
1572 destroy_tunnel (t);
1573}
1574
1575
1576/**
1562 * It's been a while, we should try to redo the KX, if we can. 1577 * It's been a while, we should try to redo the KX, if we can.
1563 * 1578 *
1564 * @param cls the `struct CadetTunnel` to do KX for. 1579 * @param cls the `struct CadetTunnel` to do KX for.
diff --git a/src/cadet/gnunet-service-cadet-new_tunnels.h b/src/cadet/gnunet-service-cadet-new_tunnels.h
index 3c88ae5f0..c867a9e82 100644
--- a/src/cadet/gnunet-service-cadet-new_tunnels.h
+++ b/src/cadet/gnunet-service-cadet-new_tunnels.h
@@ -99,6 +99,15 @@ GCT_create_tunnel (struct CadetPeer *destination);
99 99
100 100
101/** 101/**
102 * Destroys the tunnel @a t now, without delay. Used during shutdown.
103 *
104 * @param t tunnel to destroy
105 */
106void
107GCT_destroy_tunnel_now (struct CadetTunnel *t);
108
109
110/**
102 * Add a @a connection to the @a tunnel. 111 * Add a @a connection to the @a tunnel.
103 * 112 *
104 * @param t a tunnel 113 * @param t a tunnel