From 6e3b46790acf09e681f5aed8f9b28dee28b38380 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Thu, 21 Nov 2013 17:49:11 +0000 Subject: [PATCH] - destroy all connections on shutdown, so core_disconnect doesn't cause errors --- src/mesh/gnunet-service-mesh_connection.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index b77e5e0e8..d56cef1f9 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c @@ -2079,12 +2079,35 @@ GMC_init (const struct GNUNET_CONFIGURATION_Handle *c) connections = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_YES); } + +/** + * Destroy each connection on shutdown. + * + * @param cls Closure (unused). + * @param key Current key code (CID, unused). + * @param value Value in the hash map (connection) + * + * @return #GNUNET_YES, because we should continue to iterate, + */ +static int +shutdown_iterator (void *cls, + const struct GNUNET_HashCode *key, + void *value) +{ + struct MeshConnection *c = value; + + GMC_destroy (c); + return GNUNET_YES; +} + + /** * Shut down the connections subsystem. */ void GMC_shutdown (void) { + GNUNET_CONTAINER_multihashmap_iterate (connections, &shutdown_iterator, NULL); GNUNET_CONTAINER_multihashmap_destroy (connections); connections = NULL; } -- 2.25.1