gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r24987 - gnunet/src/mesh
Date: Thu, 15 Nov 2012 16:24:16 +0100

Author: bartpolot
Date: 2012-11-15 16:24:16 +0100 (Thu, 15 Nov 2012)
New Revision: 24987

Modified:
   gnunet/src/mesh/gnunet-service-mesh.c
Log:
- exponential backoff for ACK polling

Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c       2012-11-15 14:55:44 UTC (rev 
24986)
+++ gnunet/src/mesh/gnunet-service-mesh.c       2012-11-15 15:24:16 UTC (rev 
24987)
@@ -61,7 +61,9 @@
 #define MESH_DEBUG_CONNECTION   GNUNET_NO
 #define MESH_DEBUG_TIMING       __LINUX__ && GNUNET_NO
 
-#define MESH_POLL_TIME         GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 10)
+#define MESH_MAX_POLL_TIME      GNUNET_TIME_relative_multiply (\
+                                  GNUNET_TIME_UNIT_MINUTES,\
+                                  10)
 
 #if MESH_DEBUG_CONNECTION
 #define DEBUG_CONN(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
@@ -584,7 +586,12 @@
     /**
      * Task to poll peer in case of a stall.
      */
-   GNUNET_SCHEDULER_TaskIdentifier fc_poll;
+  GNUNET_SCHEDULER_TaskIdentifier fc_poll;
+
+     /**
+      * Time to use for next polling call.
+      */
+   struct GNUNET_TIME_Relative fc_poll_time;
 };
 
 
@@ -2994,7 +3001,7 @@
  * Function called if the connection to the peer has been stalled for a while,
  * possibly due to a missed ACK. Poll the peer about its ACK status.
  *
- * @param cls Closure (info about regex search).
+ * @param cls Closure (cinfo).
  * @param tc TaskContext.
  */
 static void
@@ -3020,8 +3027,11 @@
 
   GNUNET_PEER_resolve (cinfo->id, &id);
   send_prebuilt_message (&msg.header, &id, cinfo->t);
-  cinfo->fc_poll = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS,
-                                                    &tunnel_poll, cinfo);
+  cinfo->fc_poll_time = GNUNET_TIME_relative_min (
+    MESH_MAX_POLL_TIME,
+    GNUNET_TIME_relative_multiply (cinfo->fc_poll_time, 2));
+  cinfo->fc_poll = GNUNET_SCHEDULER_add_delayed (cinfo->fc_poll_time,
+                                                 &tunnel_poll, cinfo);
 }
 
 
@@ -3692,6 +3702,9 @@
     cinfo->bck_ack = delta;
     cinfo->bck_pid = -1;
 
+    cinfo->fc_poll = GNUNET_SCHEDULER_NO_TASK;
+    cinfo->fc_poll_time = GNUNET_TIME_UNIT_SECONDS;
+
     cinfo->send_buffer =
         GNUNET_malloc (sizeof(struct MeshPeerQueue *) * t->fwd_queue_max);
 
@@ -5197,8 +5210,10 @@
         if (NULL == cinfo)
           cinfo = tunnel_get_neighbor_fc (t, &dst_id);
         if (GNUNET_SCHEDULER_NO_TASK == cinfo->fc_poll)
-          cinfo->fc_poll = GNUNET_SCHEDULER_add_delayed(MESH_POLL_TIME,
-                                                        &tunnel_poll, cinfo);
+        {
+          cinfo->fc_poll = GNUNET_SCHEDULER_add_delayed (cinfo->fc_poll_time,
+                                                         &tunnel_poll, cinfo);
+        }
       }
     }
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "*********   return %d\n", data_size);
@@ -6037,6 +6052,12 @@
     cinfo->fwd_ack = ack;
     tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_ACK);
     tunnel_unlock_fwd_queues (t);
+    if (GNUNET_SCHEDULER_NO_TASK != cinfo->fc_poll)
+    {
+      GNUNET_SCHEDULER_cancel (cinfo->fc_poll);
+      cinfo->fc_poll = GNUNET_SCHEDULER_NO_TASK;
+      cinfo->fc_poll_time = GNUNET_TIME_UNIT_SECONDS;
+    }
   }
   else
   {




reply via email to

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