From: Bart Polot Date: Mon, 18 Nov 2013 19:10:50 +0000 (+0000) Subject: - destroy channels when tunnels is being destroyed (but complain: channels should... X-Git-Tag: initial-import-from-subversion-38251~6020 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0018daf05f889a759964ae8f2a89e18922e72b74;p=oweals%2Fgnunet.git - destroy channels when tunnels is being destroyed (but complain: channels should have been destroyed first). Probably wrong shutdown sequence. --- diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c index 059f1231b..45c8c6044 100644 --- a/src/mesh/gnunet-service-mesh_channel.c +++ b/src/mesh/gnunet-service-mesh_channel.c @@ -847,45 +847,6 @@ channel_save_copy (struct MeshChannel *ch, } -/** - * Destroy a channel and free all resources. - * - * @param ch Channel to destroy. - */ -static void -channel_destroy (struct MeshChannel *ch) -{ - struct MeshClient *c; - - if (NULL == ch) - return; - - LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying channel %s:%u\n", - GMT_2s (ch->t), ch->gid); - GMCH_debug (ch); - - c = ch->root; - if (NULL != c) - { - GML_channel_remove (c, ch->lid_root, ch); - } - - c = ch->dest; - if (NULL != c) - { - GML_channel_remove (c, ch->lid_dest, ch); - } - - channel_rel_free_all (ch->root_rel); - channel_rel_free_all (ch->dest_rel); - - GMT_remove_channel (ch->t, ch); - GNUNET_STATISTICS_update (stats, "# channels", -1, GNUNET_NO); - - GNUNET_free (ch); -} - - /** * Create a new channel. * @@ -1011,6 +972,53 @@ handle_loopback (struct MeshChannel *ch, /******************************************************************************/ +/** + * Destroy a channel and free all resources. + * + * @param ch Channel to destroy. + */ +void +GMCH_destroy (struct MeshChannel *ch); + +/** + * Destroy a channel and free all resources. + * + * @param ch Channel to destroy. + */ +void +GMCH_destroy (struct MeshChannel *ch) +{ + struct MeshClient *c; + + if (NULL == ch) + return; + + LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying channel %s:%u\n", + GMT_2s (ch->t), ch->gid); + GMCH_debug (ch); + + c = ch->root; + if (NULL != c) + { + GML_channel_remove (c, ch->lid_root, ch); + } + + c = ch->dest; + if (NULL != c) + { + GML_channel_remove (c, ch->lid_dest, ch); + } + + channel_rel_free_all (ch->root_rel); + channel_rel_free_all (ch->dest_rel); + + GMT_remove_channel (ch->t, ch); + GNUNET_STATISTICS_update (stats, "# channels", -1, GNUNET_NO); + + GNUNET_free (ch); +} + + /** * Get channel ID. * @@ -1462,7 +1470,7 @@ GMCH_handle_local_destroy (struct MeshChannel *ch, t = ch->t; GMCH_send_destroy (ch); - channel_destroy (ch); + GMCH_destroy (ch); GMT_destroy_if_empty (t); } @@ -1776,7 +1784,7 @@ GMCH_handle_create (struct MeshTunnel3 *t, { LOG (GNUNET_ERROR_TYPE_DEBUG, " not loopback: destroy now\n"); channel_send_nack (ch); - channel_destroy (ch); + GMCH_destroy (ch); } return NULL; } @@ -1809,7 +1817,7 @@ void GMCH_handle_nack (struct MeshChannel *ch) { send_client_nack (ch); - channel_destroy (ch); + GMCH_destroy (ch); } @@ -1882,7 +1890,7 @@ GMCH_handle_destroy (struct MeshChannel *ch, t = ch->t; GMCH_send_destroy (ch); - channel_destroy (ch); + GMCH_destroy (ch); GMT_destroy_if_empty (t); } diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index bc8aefcc2..7198a2474 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c @@ -1639,8 +1639,11 @@ GMT_destroy_if_empty (struct MeshTunnel3 *t) void GMT_destroy (struct MeshTunnel3 *t) { - struct MeshTConnection *iter; - struct MeshTConnection *next; + struct MeshTConnection *iter_c; + struct MeshTConnection *next_c; + struct MeshTChannel *iter_ch; + struct MeshTChannel *next_ch; + if (NULL == t) return; @@ -1650,10 +1653,16 @@ GMT_destroy (struct MeshTunnel3 *t) // if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (tunnels, &t->id, t)) // GNUNET_break (0); - for (iter = t->connection_head; NULL != iter; iter = next) + for (iter_c = t->connection_head; NULL != iter_c; iter_c = next_c) { - next = iter->next; - GMC_destroy (iter->c); + next_c = iter_c->next; + GMC_destroy (iter_c->c); + } + for (iter_ch = t->channel_head; NULL != iter_ch; iter_ch = next_ch) + { + next_ch = iter_ch->next; + GMCH_destroy (iter_ch->ch); + GNUNET_break (0); } GNUNET_STATISTICS_update (stats, "# tunnels", -1, GNUNET_NO);