gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r9453 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r9453 - gnunet/src/util
Date: Tue, 10 Nov 2009 13:26:10 -0700

Author: grothoff
Date: 2009-11-10 13:26:10 -0700 (Tue, 10 Nov 2009)
New Revision: 9453

Modified:
   gnunet/src/util/client.c
Log:
use exponential back-off of 1ms to 1s for (connect) retries by clients

Modified: gnunet/src/util/client.c
===================================================================
--- gnunet/src/util/client.c    2009-11-10 20:20:32 UTC (rev 9452)
+++ gnunet/src/util/client.c    2009-11-10 20:26:10 UTC (rev 9453)
@@ -78,7 +78,7 @@
   GNUNET_SCHEDULER_TaskIdentifier reconnect_task;
 
   /**
-   * Timeout.
+   * Timeout for the operation overall.
    */
   struct GNUNET_TIME_Absolute timeout;
 
@@ -216,6 +216,12 @@
   struct GNUNET_TIME_Absolute receive_timeout;
 
   /**
+   * Current value for our incremental back-off (for
+   * connect re-tries).
+   */
+  struct GNUNET_TIME_Relative back_off;
+
+  /**
    * Number of bytes in received_buf that are valid.
    */
   size_t received_pos;
@@ -307,6 +313,7 @@
   ret->sched = sched;
   ret->service_name = GNUNET_strdup (service_name);
   ret->cfg = GNUNET_CONFIGURATION_dup (cfg);
+  ret->back_off = GNUNET_TIME_UNIT_MILLISECONDS;
   return ret;
 }
 
@@ -768,7 +775,10 @@
       th->sock->sock = do_connect (th->sock->sched,
                                    th->sock->service_name, th->sock->cfg);
       GNUNET_assert (NULL != th->sock->sock);
-      delay = GNUNET_TIME_relative_min (delay, GNUNET_TIME_UNIT_SECONDS);
+      delay = GNUNET_TIME_relative_min (delay, th->sock->back_off);
+      th->sock->back_off 
+       = GNUNET_TIME_relative_min (GNUNET_TIME_relative_multiply 
(th->sock->back_off, 2),
+                                   GNUNET_TIME_UNIT_SECONDS);
 #if DEBUG_CLIENT
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Transmission failed %u times, trying again in %llums.\n",





reply via email to

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