gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r30169 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r30169 - gnunet/src/mesh
Date: Fri, 11 Oct 2013 19:51:11 +0200

Author: bartpolot
Date: 2013-10-11 19:51:11 +0200 (Fri, 11 Oct 2013)
New Revision: 30169

Modified:
   gnunet/src/mesh/gnunet-service-mesh_channel.c
   gnunet/src/mesh/gnunet-service-mesh_tunnel.c
Log:
- avoid infinite ACK loops when creating loopback channels


Modified: gnunet/src/mesh/gnunet-service-mesh_channel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.c       2013-10-11 17:44:02 UTC 
(rev 30168)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.c       2013-10-11 17:51:11 UTC 
(rev 30169)
@@ -603,7 +603,7 @@
  * Confirm we got a channel create.
  *
  * @param ch The channel to confirm.
- * @param fwd Should we send the ACK fwd?
+ * @param fwd Should we send a FWD ACK? (going dest->root)
  */
 static void
 channel_send_ack (struct MeshChannel *ch, int fwd)
@@ -652,7 +652,10 @@
       /* TODO return? */
     }
   }
-  channel_send_ack (ch, fwd);
+
+  /* In case of a FWD ACk (SYNACK) send a BCK ACK (ACK). */
+  if (fwd)
+    channel_send_ack (ch, !fwd);
 }
 
 
@@ -866,8 +869,8 @@
 
   type = ntohs (msgh->type);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Loopback %s message!\n",
-       GNUNET_MESH_DEBUG_M2S (type));
+       "Loopback %s %s message!\n",
+       fwd ? "FWD" : "BCK", GNUNET_MESH_DEBUG_M2S (type));
 
   switch (type)
   {
@@ -1521,9 +1524,13 @@
 
   chid = ntohl (msg->chid);
 
-  /* Create channel */
-  ch = channel_new (t, NULL, 0);
-  ch->gid = chid;
+  ch = GMT_get_channel (t, chid);
+  if (NULL == ch)
+  {
+    /* Create channel */
+    ch = channel_new (t, NULL, 0);
+    ch->gid = chid;
+  }
   channel_set_options (ch, ntohl (msg->opt));
 
   /* Find a destination client */
@@ -1543,8 +1550,8 @@
     LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! Reliable\n");
 
   GMCH_send_create (ch);
+  channel_send_ack (ch, fwd);
   GMCH_send_data_ack (ch, fwd);
-  channel_send_ack (ch, !fwd);
 
   if (GNUNET_NO == ch->dest_rel->client_ready)
   {
@@ -1619,8 +1626,8 @@
 GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
                             struct MeshChannel *ch, int fwd)
 {
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Send on Channel %s:%X %s\n",
-       GMT_2s (ch->t), ch->gid, fwd ? "FWD" : "BCK");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Send %s on channel %s\n",
+       fwd ? "FWD" : "BCK", GMCH_2s (ch));
   LOG (GNUNET_ERROR_TYPE_DEBUG, "  %s\n",
        GNUNET_MESH_DEBUG_M2S (ntohs (message->type)));
 

Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2013-10-11 17:44:02 UTC 
(rev 30168)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2013-10-11 17:51:11 UTC 
(rev 30169)
@@ -33,7 +33,10 @@
 
 #define LOG(level, ...) GNUNET_log_from(level,"mesh-tun",__VA_ARGS__)
 
+#define START_FUNCTION LOG(GNUNET_ERROR_TYPE_DEBUG, "%s start\n", __FUNCTION__)
+#define END_FUNCTION LOG(GNUNET_ERROR_TYPE_DEBUG, "%s end\n", __FUNCTION__)
 
+
 
/******************************************************************************/
 /********************************   STRUCTS  
**********************************/
 
/******************************************************************************/
@@ -371,6 +374,8 @@
                   const struct GNUNET_MESH_ChannelCreate *msg,
                   int fwd)
 {
+  ;
+
   struct MeshTChannel *tch;
   struct MeshChannel *ch;
   size_t size;
@@ -398,6 +403,8 @@
   tch = GNUNET_new (struct MeshTChannel);
   tch->ch = ch;
   GNUNET_CONTAINER_DLL_insert (t->channel_head, t->channel_tail, tch);
+
+  ;
 }
 
 void




reply via email to

[Prev in Thread] Current Thread [Next in Thread]