gnunet

Main GNUnet Logic
Log | Files | Refs | Submodules | README | LICENSE

commit e6b80ab7b7de86928aafb7ccfd39a2019f256fd6
parent f8f51150a4f28fecd7f0997227c5c15edfe9dd02
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 22 Jan 2017 00:10:26 +0100

ensure tunnels are shutdown at the right time during shutdown

Diffstat:
Msrc/cadet/cadet.conf.in | 2+-
Msrc/cadet/gnunet-service-cadet-new.c | 29++++++++++++++++++++++++++++-
Msrc/cadet/gnunet-service-cadet-new_tunnels.c | 15+++++++++++++++
Msrc/cadet/gnunet-service-cadet-new_tunnels.h | 9+++++++++
4 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/src/cadet/cadet.conf.in b/src/cadet/cadet.conf.in @@ -3,7 +3,7 @@ FORCESTART = YES AUTOSTART = @AUTOSTART@ @JAVAPORT@PORT = 2096 HOSTNAME = localhost -BINARY = gnunet-service-cadet-new +BINARY = gnunet-service-cadet ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; UNIXPATH = $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 @@ -311,6 +311,30 @@ GSC_bind (struct CadetClient *c, /** + * Callback invoked on all peers to destroy all tunnels + * that may still exist. + * + * @param cls NULL + * @param pid identify of a peer + * @param value a `struct CadetPeer` that may still have a tunnel + * @return #GNUNET_OK (iterate over all entries) + */ +static int +destroy_tunnels_now (void *cls, + const struct GNUNET_PeerIdentity *pid, + void *value) +{ + struct CadetPeer *cp = value; + struct CadetTunnel *t = GCP_get_tunnel (cp, + GNUNET_NO); + + if (NULL != t) + GCT_destroy_tunnel_now (t); + return GNUNET_OK; +} + + +/** * Task run during shutdown. * * @param cls unused @@ -338,7 +362,10 @@ shutdown_task (void *cls) GNUNET_CONTAINER_multihashmap_destroy (loose_channels); loose_channels = NULL; } - /* All channels, connections and CORE must be down before this point. */ + /* Destroy tunnels. Note that all channels must be destroyed first! */ + GCP_iterate_all (&destroy_tunnels_now, + NULL); + /* All tunnels, channels, connections and CORE must be down before this point. */ GCP_destroy_all_peers (); if (NULL != peers) { diff --git 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, /** + * Destroys the tunnel @a t now, without delay. Used during shutdown. + * + * @param t tunnel to destroy + */ +void +GCT_destroy_tunnel_now (struct CadetTunnel *t) +{ + GNUNET_assert (0 == + GNUNET_CONTAINER_multihashmap32_size (t->channels)); + GNUNET_SCHEDULER_cancel (t->destroy_task); + destroy_tunnel (t); +} + + +/** * It's been a while, we should try to redo the KX, if we can. * * @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 @@ -99,6 +99,15 @@ GCT_create_tunnel (struct CadetPeer *destination); /** + * Destroys the tunnel @a t now, without delay. Used during shutdown. + * + * @param t tunnel to destroy + */ +void +GCT_destroy_tunnel_now (struct CadetTunnel *t); + + +/** * Add a @a connection to the @a tunnel. * * @param t a tunnel