- fixes in local
authorBart Polot <bart@net.in.tum.de>
Thu, 10 Oct 2013 18:23:48 +0000 (18:23 +0000)
committerBart Polot <bart@net.in.tum.de>
Thu, 10 Oct 2013 18:23:48 +0000 (18:23 +0000)
src/mesh/gnunet-service-mesh_channel.c
src/mesh/gnunet-service-mesh_local.c
src/mesh/gnunet-service-mesh_local.h

index d2935ec4e0e80de19277551ba2766f2da0fc58ea..3607ae56c3b8b3a58e9fc608117a2d3cf68834b5 100644 (file)
@@ -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;
 }
index a1ff2b12c1c2a9832db0028ce5f7e0881eabc600..2d6214d3e5a82bf67c7f122e5c90b2e3540d7edc 100644 (file)
@@ -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,
index e91165dec50c9a95df06f21c9243d6265a7581f6..6b126a2f777cec2eb674951c3c69c2bcbe61ba17 100644 (file)
@@ -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.