gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r27118 - gnunet/src/mesh
Date: Tue, 14 May 2013 13:14:13 +0200

Author: bartpolot
Date: 2013-05-14 13:14:13 +0200 (Tue, 14 May 2013)
New Revision: 27118

Modified:
   gnunet/src/mesh/gnunet-service-mesh-new.c
Log:
- fix ack value sent on data

Modified: gnunet/src/mesh/gnunet-service-mesh-new.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh-new.c   2013-05-14 11:05:09 UTC (rev 
27117)
+++ gnunet/src/mesh/gnunet-service-mesh-new.c   2013-05-14 11:14:13 UTC (rev 
27118)
@@ -2643,6 +2643,7 @@
   struct GNUNET_PeerIdentity dst_id;
   struct MeshFlowControl *fc;
   size_t data_size;
+  uint16_t type;
 
   peer->core_transmit = NULL;
 
@@ -2684,6 +2685,7 @@
   t = queue->tunnel;
   GNUNET_assert (0 < t->pending_messages);
   t->pending_messages--;
+  type = 0;
 
   /* Fill buf */
   switch (queue->type)
@@ -2703,17 +2705,7 @@
     case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
       data_size = send_core_data_raw (queue->cls, size, buf);
       msg = (struct GNUNET_MessageHeader *) buf;
-      switch (ntohs (msg->type)) // Type of preconstructed message
-      {
-        case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
-          tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_UNICAST);
-          break;
-        case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
-          tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN);
-          break;
-        default:
-            break;
-      }
+      type = ntohs (msg->type);
       break;
     case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE:
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "*********   path create\n");
@@ -2730,38 +2722,23 @@
                   queue->type);
       data_size = 0;
   }
-  switch (queue->type)
+
+  /* Free queue, but cls was freed by send_core_* */
+  queue_destroy (queue, GNUNET_NO);
+
+  /* Send ACK if needed, after accounting for sent ID in fc->queue_n */
+  switch (type)
   {
     case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
+      tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_UNICAST);
+      break;
     case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
-//         if (cinfo->send_buffer[cinfo->send_buffer_start] != queue)
-//         { FIXME
-//           GNUNET_break (0);
-//           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-//                       "at pos %u (%p) != %p\n",
-//                       cinfo->send_buffer_start,
-//                       cinfo->send_buffer[cinfo->send_buffer_start],
-//                       queue);
-//         }
-//         if (cinfo->send_buffer_n > 0)
-//         {
-//           cinfo->send_buffer[cinfo->send_buffer_start] = NULL;
-//           cinfo->send_buffer_n--;
-//           cinfo->send_buffer_start++;
-//           cinfo->send_buffer_start %= t->fwd_queue_max;
-//         }
-//         else
-//         {
-//           GNUNET_break (0);
-//         }
+      tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN);
       break;
     default:
       break;
   }
 
-  /* Free queue, but cls was freed by send_core_* */
-  queue_destroy (queue, GNUNET_NO);
-
   if (GNUNET_YES == t->destroy && 0 == t->pending_messages)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "*********  destroying tunnel!\n");
@@ -2786,24 +2763,26 @@
                                             &queue_send,
                                             peer);
   }
-  else
+  else if (NULL != peer->queue_head)
   {
-    if (NULL != peer->queue_head)
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "*********   %s stalled\n",
+                GNUNET_i2s(&my_full_id));
+    if (peer->id == t->next_hop)
+      fc = &t->next_fc;
+    else if (peer->id == t->prev_hop)
+      fc = &t->prev_fc;
+    else
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                  "*********   %s stalled\n",
-                  GNUNET_i2s(&my_full_id));
-      if (peer->id == t->next_hop)
-        fc = &t->next_fc;
-      else
-        fc = &t->prev_fc;
-      if (GNUNET_SCHEDULER_NO_TASK == fc->poll_task)
-      {
-        fc->t = t;
-        fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
-                                                      &tunnel_poll, fc);
-      }
+      GNUNET_break (0);
+      fc = NULL;
     }
+    if (NULL != fc && GNUNET_SCHEDULER_NO_TASK == fc->poll_task)
+    {
+      fc->t = t;
+      fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
+                                                    &tunnel_poll, fc);
+    }
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "*********   return %d\n", data_size);
   return data_size;




reply via email to

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