From 990ca23b4da56d67f093d0ad967731998d9851fb Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Thu, 10 Oct 2013 18:23:48 +0000 Subject: - fixes in local --- src/mesh/gnunet-service-mesh_channel.c | 7 +++- src/mesh/gnunet-service-mesh_local.c | 61 ++++++++++++++-------------------- src/mesh/gnunet-service-mesh_local.h | 10 +++--- 3 files changed, 37 insertions(+), 41 deletions(-) (limited to 'src/mesh') diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c index d2935ec4e..3607ae56c 100644 --- a/src/mesh/gnunet-service-mesh_channel.c +++ b/src/mesh/gnunet-service-mesh_channel.c @@ -1380,7 +1380,12 @@ GMCH_handle_create (const struct GNUNET_MESH_ChannelCreate *msg, GMCH_send_create (ch); GMCH_send_ack (ch, fwd); - GML_send_ack (ch, !fwd); + + if (GNUNET_NO == ch->dest_rel->client_ready) + { + GML_send_ack (ch->dest, ch->lid_dest); + ch->dest_rel->client_ready = GNUNET_YES; + } return ch; } diff --git a/src/mesh/gnunet-service-mesh_local.c b/src/mesh/gnunet-service-mesh_local.c index a1ff2b12c..2d6214d3e 100644 --- a/src/mesh/gnunet-service-mesh_local.c +++ b/src/mesh/gnunet-service-mesh_local.c @@ -913,10 +913,10 @@ GML_channel_remove (struct MeshClient *client, uint32_t chid, struct MeshChannel *ch) { - if (chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV) - GNUNET_CONTAINER_multihashmap32_remove (c->incoming_channels, chid, ch); - else if (chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_CLI) - GNUNET_CONTAINER_multihashmap32_remove (c->own_channels, chid, ch); + if (GNUNET_MESH_LOCAL_CHANNEL_ID_SERV <= chid) + GNUNET_CONTAINER_multihashmap32_remove (client->incoming_channels, chid, ch); + else if (GNUNET_MESH_LOCAL_CHANNEL_ID_CLI <= chid) + GNUNET_CONTAINER_multihashmap32_remove (client->own_channels, chid, ch); else GNUNET_break (0); } @@ -978,25 +978,32 @@ GML_client_get_by_port (uint32_t port) * * @param c Client whose tunnel to delete. * @param ch Channel which should be deleted. + * @param id Channel ID. */ void -GML_client_delete_channel (struct MeshClient *c, struct MeshChannel *ch) +GML_client_delete_channel (struct MeshClient *c, + struct MeshChannel *ch, + MESH_ChannelNumber id) { int res; - if (c == ch->root) + if (GNUNET_MESH_LOCAL_CHANNEL_ID_SERV <= id) { - res = GNUNET_CONTAINER_multihashmap32_remove (c->own_channels, - ch->lid_root, ch); + res = GNUNET_CONTAINER_multihashmap32_remove (c->incoming_channels, + id, ch); if (GNUNET_YES != res) - LOG (GNUNET_ERROR_TYPE_DEBUG, "client_delete_channel owner KO\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, "client_delete_channel dest KO\n"); } - if (c == ch->dest) + else if (GNUNET_MESH_LOCAL_CHANNEL_ID_CLI <= id) { - res = GNUNET_CONTAINER_multihashmap32_remove (c->incoming_channels, - ch->lid_dest, ch); + res = GNUNET_CONTAINER_multihashmap32_remove (c->own_channels, + id, ch); if (GNUNET_YES != res) - LOG (GNUNET_ERROR_TYPE_DEBUG, "client_delete_tunnel client KO\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, "client_delete_tunnel root KO\n"); + } + else + { + GNUNET_break (0); } } @@ -1005,39 +1012,21 @@ GML_client_delete_channel (struct MeshClient *c, struct MeshChannel *ch) * * If the client was already allowed to send data, do nothing. * - * @param ch Channel on which to send the ACK. * @param c Client to whom send the ACK. - * @param fwd Set to GNUNET_YES for FWD ACK (dest->root) + * @param id Channel ID to use */ void -GML_send_ack (struct MeshChannel *ch, int fwd) +GML_send_ack (struct MeshClient *c, MESH_ChannelNumber id) { struct GNUNET_MESH_LocalAck msg; - struct MeshChannelReliability *rel; - struct MeshClient *c; - - c = fwd ? ch->root : ch->dest; - rel = fwd ? ch->root_rel : ch->dest_rel; - - if (GNUNET_YES == rel->client_ready) - return; /* don't send double ACKs to client */ - - rel->client_ready = GNUNET_YES; LOG (GNUNET_ERROR_TYPE_DEBUG, - "send local %s ack on %s:%X towards %p\n", - fwd ? "FWD" : "BCK", peer2s (ch->t->peer), ch->gid, c); + "send local %s ack on %X towards %p\n", + id < GNUNET_MESH_LOCAL_CHANNEL_ID_SERV ? "FWD" : "BCK", id, c); - if (NULL == c - || ( fwd && (0 == ch->lid_root || c != ch->root)) - || (!fwd && (0 == ch->lid_dest || c != ch->dest)) ) - { - GNUNET_break (0); - return; - } msg.header.size = htons (sizeof (msg)); msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK); - msg.channel_id = htonl (fwd ? ch->lid_root : ch->lid_dest); + msg.channel_id = htonl (id); GNUNET_SERVER_notification_context_unicast (nc, c->handle, &msg.header, diff --git a/src/mesh/gnunet-service-mesh_local.h b/src/mesh/gnunet-service-mesh_local.h index e91165dec..6b126a2f7 100644 --- a/src/mesh/gnunet-service-mesh_local.h +++ b/src/mesh/gnunet-service-mesh_local.h @@ -141,21 +141,23 @@ GML_client_get_by_port (uint32_t port); * * @param c Client whose tunnel to delete. * @param ch Channel which should be deleted. + * @param id Channel ID. */ void -GML_client_delete_channel (struct MeshClient *c, struct MeshChannel *ch); +GML_client_delete_channel (struct MeshClient *c, + struct MeshChannel *ch, + MESH_ChannelNumber id); /** * Build a local ACK message and send it to a local client, if needed. * * If the client was already allowed to send data, do nothing. * - * @param ch Channel on which to send the ACK. * @param c Client to whom send the ACK. - * @param fwd Set to GNUNET_YES for FWD ACK (dest->root) + * @param id Channel ID to use */ void -GML_send_ack (struct MeshChannel *ch, int fwd); +GML_send_ack (struct MeshClient *c, MESH_ChannelNumber id); /** * Notify the appropriate client that a new incoming channel was created. -- cgit v1.2.3