}
-/**
- * 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.
*
/******************************************************************************/
+/**
+ * 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.
*
t = ch->t;
GMCH_send_destroy (ch);
- channel_destroy (ch);
+ GMCH_destroy (ch);
GMT_destroy_if_empty (t);
}
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " not loopback: destroy now\n");
channel_send_nack (ch);
- channel_destroy (ch);
+ GMCH_destroy (ch);
}
return NULL;
}
GMCH_handle_nack (struct MeshChannel *ch)
{
send_client_nack (ch);
- channel_destroy (ch);
+ GMCH_destroy (ch);
}
t = ch->t;
GMCH_send_destroy (ch);
- channel_destroy (ch);
+ GMCH_destroy (ch);
GMT_destroy_if_empty (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;
// 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);