aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-08-02 00:47:19 +0000
committerBart Polot <bart@net.in.tum.de>2013-08-02 00:47:19 +0000
commitabb29a80b038b2f73bbc74621285865db4a6e7d5 (patch)
treecb392ff38732e571460e784313fcbd940f2a4739 /src
parent8a017c1db5aa966285e171211a0f10ad10bae556 (diff)
downloadgnunet-abb29a80b038b2f73bbc74621285865db4a6e7d5.tar.gz
gnunet-abb29a80b038b2f73bbc74621285865db4a6e7d5.zip
- channel destroy iterator
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-service-mesh-enc.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c
index da54db74f..3ae0c1f9c 100644
--- a/src/mesh/gnunet-service-mesh-enc.c
+++ b/src/mesh/gnunet-service-mesh-enc.c
@@ -3404,8 +3404,8 @@ connection_send_destroy (struct MeshConnection *c)
3404 3404
3405 3405
3406/** 3406/**
3407 * Send a message to all clients in this channel that the channel 3407 * Send a message to all clients (local and remote) of this channel
3408 * is no longer valid. 3408 * notifying that the channel is no longer valid.
3409 * 3409 *
3410 * If some peer or client should not receive the message, 3410 * If some peer or client should not receive the message,
3411 * should be zero'ed out before calling this function. 3411 * should be zero'ed out before calling this function.
@@ -3598,6 +3598,7 @@ channel_destroy (struct MeshChannel *ch)
3598 channel_rel_free_all (ch->bck_rel); 3598 channel_rel_free_all (ch->bck_rel);
3599 } 3599 }
3600 3600
3601 GNUNET_CONTAINER_DLL_remove (ch->t->channel_head, ch->t->channel_tail, ch);
3601 GNUNET_STATISTICS_update (stats, "# channels", -1, GNUNET_NO); 3602 GNUNET_STATISTICS_update (stats, "# channels", -1, GNUNET_NO);
3602 3603
3603 GNUNET_free (ch); 3604 GNUNET_free (ch);
@@ -3657,47 +3658,42 @@ channel_set_options (struct MeshChannel *ch, uint32_t options)
3657 3658
3658 3659
3659/** 3660/**
3660 * Iterator for deleting each tunnel whose client endpoint disconnected. 3661 * Iterator for deleting each channel whose client endpoint disconnected.
3661 * 3662 *
3662 * @param cls Closure (client that has disconnected). 3663 * @param cls Closure (client that has disconnected).
3663 * @param key The local tunnel id (used to access the hashmap). 3664 * @param key The local channel id (used to access the hashmap).
3664 * @param value The value stored at the key (tunnel to destroy). 3665 * @param value The value stored at the key (channel to destroy).
3665 * 3666 *
3666 * @return GNUNET_OK, keep iterating. 3667 * @return GNUNET_OK, keep iterating.
3667 */ 3668 */
3668static int 3669static int
3669tunnel_destroy_iterator (void *cls, 3670channel_destroy_iterator (void *cls,
3670 uint32_t key, 3671 uint32_t key,
3671 void *value) 3672 void *value)
3672{ 3673{
3673 struct MeshTunnel *t = value; 3674 struct MeshChannel *ch = value;
3674 struct MeshClient *c = cls; 3675 struct MeshClient *c = cls;
3676 struct MeshTunnel2 *t;
3675 3677
3676 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3678 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3677 " Tunnel %X / %X destroy, due to client %u shutdown.\n", 3679 " Channel %X / %X destroy, due to client %u shutdown.\n",
3678 t->local_tid, t->local_tid_dest, c->id); 3680 ch->id, ch->id_dest, c->id);
3679 client_delete_tunnel (c, t); 3681
3680 if (c == t->client) 3682 if (c == ch->client)
3681 { 3683 {
3682 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Client %u is destination.\n", c->id); 3684 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Client %u is destination.\n", c->id);
3683 t->client = NULL; 3685 ch->client = NULL;
3684 if (0 != t->next_hop) /* destroy could come before a path is used */
3685 {
3686 GNUNET_PEER_change_rc (t->next_hop, -1);
3687 t->next_hop = 0;
3688 }
3689 } 3686 }
3690 if (c == t->owner) 3687 if (c == ch->owner)
3691 { 3688 {
3692 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Client %u is owner.\n", c->id); 3689 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Client %u is owner.\n", c->id);
3693 t->owner = NULL; 3690 ch->owner = NULL;
3694 if (0 != t->prev_hop) { /* destroy could come before a path is used */
3695 GNUNET_PEER_change_rc (t->prev_hop, -1);
3696 t->prev_hop = 0;
3697 }
3698 } 3691 }
3699 3692
3700 tunnel_destroy_empty (t); 3693 t = ch->t;
3694 channel_send_destroy (ch);
3695 channel_destroy (ch);
3696 tunnel_destroy_if_empty (t);
3701 3697
3702 return GNUNET_OK; 3698 return GNUNET_OK;
3703} 3699}