From: Bart Polot Date: Mon, 22 Jul 2013 16:34:03 +0000 (+0000) Subject: - cancel retransmissions on destroy X-Git-Tag: initial-import-from-subversion-38251~8133 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0d77524391e50cce781c29f5f07a85e5391c731c;p=oweals%2Fgnunet.git - cancel retransmissions on destroy --- diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index c2f9e0060..d291e3de5 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -2690,6 +2690,40 @@ tunnel_free_reliable_message (struct MeshReliableMessage *copy) } +/** + * Destroy all reliable messages queued for a tunnel, + * during a tunnel destruction. + * Frees the reliability structure itself. + * + * @param rel Reliability data for a tunnel. + */ +static void +tunnel_free_reliable_all (struct MeshTunnelReliability *rel) +{ + struct MeshReliableMessage *copy; + struct MeshReliableMessage *next; + + if (NULL == rel) + return; + + for (copy = rel->head_recv; NULL != copy; copy = next) + { + next = copy->next; + GNUNET_CONTAINER_DLL_remove (rel->head_recv, rel->tail_recv, copy); + GNUNET_free (copy); + } + for (copy = rel->head_sent; NULL != copy; copy = next) + { + next = copy->next; + GNUNET_CONTAINER_DLL_remove (rel->head_recv, rel->tail_recv, copy); + GNUNET_free (copy); + } + if (GNUNET_SCHEDULER_NO_TASK != rel->retry_task) + GNUNET_SCHEDULER_cancel (rel->retry_task); + GNUNET_free (rel); +} + + /** * Mark future messages as ACK'd. * @@ -3000,9 +3034,9 @@ tunnel_send_destroy (struct MeshTunnel *t) /** * Destroy the tunnel. - * + * * This function does not generate any warning traffic to clients or peers. - * + * * Tasks: * Remove the tunnel from peer_info's and clients' hashmaps. * Cancel messages belonging to this tunnel queued to neighbors. @@ -3024,17 +3058,11 @@ tunnel_destroy (struct MeshTunnel *t) r = GNUNET_OK; c = t->owner; -#if MESH_DEBUG - { - struct GNUNET_PeerIdentity id; - GNUNET_PEER_resolve (t->id.oid, &id); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying tunnel %s [%x]\n", - GNUNET_i2s (&id), t->id.tid); - if (NULL != c) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id); - } -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying tunnel %s [%x]\n", + GNUNET_i2s (GNUNET_PEER_resolve2 (t->id.oid)), t->id.tid); + if (NULL != c) + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id); GNUNET_CRYPTO_hash (&t->id, sizeof (struct MESH_TunnelID), &hash); if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (tunnels, &hash, t)) @@ -3072,6 +3100,11 @@ tunnel_destroy (struct MeshTunnel *t) } } + if(GNUNET_YES == t->reliable) + { + tunnel_free_reliable_all (t->fwd_rel); + tunnel_free_reliable_all (t->bck_rel); + } if (0 != t->prev_hop) { peer_cancel_queues (t->prev_hop, t);