* @return GNUNET_OK if message is fine, GNUNET_SYSERR otherwise.
*/
int
-check_ephemeral (struct MeshTunnel3 *t,
+check_ephemeral (struct MeshTunnel3 *t,
const struct GNUNET_MESH_KX_Ephemeral *msg)
{
/* Check message size */
}
+/**
+ * Called only on shutdown, destroy every tunnel.
+ *
+ * @param cls Closure (unused).
+ * @param key Current public key.
+ * @param value Value in the hash map (tunnel).
+ *
+ * @return #GNUNET_YES, so we should continue to iterate,
+ */
+static int
+destroy_iterator (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
+{
+ struct MeshTunnel3 *t = value;
+
+ GMT_destroy (t);
+ return GNUNET_YES;
+}
+
+
/**
* Demultiplex data per channel and call appropriate channel handler.
*
GNUNET_SCHEDULER_cancel (rekey_task);
rekey_task = GNUNET_SCHEDULER_NO_TASK;
}
+ GNUNET_CONTAINER_multipeermap_iterate (tunnels, &destroy_iterator, NULL);
GNUNET_CONTAINER_multipeermap_destroy (tunnels);
}
{
struct MeshTConnection *iter;
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Tunnel empty: destroying scheduled\n");
for (iter = t->connection_head; NULL != iter; iter = iter->next)
{
GMC_send_destroy (iter->c);
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;
LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying tunnel %s\n", GMP_2s (t->peer));
-// if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (tunnels, &t->id, t))
-// GNUNET_break (0);
+ GNUNET_break (GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_remove (tunnels,
+ GMP_get_id (t->peer), t));
- for (iter = t->connection_head; NULL != iter; iter = next)
+ for (iter_c = t->connection_head; NULL != iter_c; iter_c = next_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 = iter->next;
- GMC_destroy (iter->c);
+ next_ch = iter_ch->next;
+ GMCH_destroy (iter_ch->ch);
+ /* Should only happen on shutdown, but it's ok. */
}
GNUNET_STATISTICS_update (stats, "# tunnels", -1, GNUNET_NO);
unsigned int cs;
unsigned int buffer;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Tunnel send connection ACKs on %s\n",
GMT_2s (t));
* @param fwd Was this a FWD going message?
* @param size Size of the message.
*/
-static void
+static void
message_sent (void *cls,
struct MeshConnection *c,
struct MeshConnectionQueue *q,
return "(NULL)";
return GMP_2s (t->peer);
-}
\ No newline at end of file
+}