gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r24188 - gnunet/src/fs


From: gnunet
Subject: [GNUnet-SVN] r24188 - gnunet/src/fs
Date: Fri, 5 Oct 2012 09:55:28 +0200

Author: grothoff
Date: 2012-10-05 09:55:28 +0200 (Fri, 05 Oct 2012)
New Revision: 24188

Modified:
   gnunet/src/fs/fs_api.h
   gnunet/src/fs/fs_download.c
   gnunet/src/fs/fs_search.c
Log:
-trying to fix bratao's 100% CPU bug, even though I wonder if this can really 
be it, as there was a 1s delay already; anyway, exponential back-off is better

Modified: gnunet/src/fs/fs_api.h
===================================================================
--- gnunet/src/fs/fs_api.h      2012-10-05 07:53:54 UTC (rev 24187)
+++ gnunet/src/fs/fs_api.h      2012-10-05 07:55:28 UTC (rev 24188)
@@ -1536,6 +1536,11 @@
   struct GNUNET_TIME_Absolute start_time;
 
   /**
+   * How long to wait before we try to reconnect to FS service?
+   */
+  struct GNUNET_TIME_Relative reconnect_backoff;
+
+  /**
    * ID of a task that is using this struct and that must be cancelled
    * when the search is being stopped (if not
    * GNUNET_SCHEDULER_NO_TASK).  Used for the task that adds some
@@ -1900,6 +1905,11 @@
   struct GNUNET_TIME_Absolute start_time;
 
   /**
+   * How long to wait before we try to reconnect to FS service?
+   */
+  struct GNUNET_TIME_Relative reconnect_backoff;
+
+  /**
    * Desired level of anonymity.
    */
   uint32_t anonymity;

Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2012-10-05 07:53:54 UTC (rev 24187)
+++ gnunet/src/fs/fs_download.c 2012-10-05 07:55:28 UTC (rev 24188)
@@ -1436,10 +1436,18 @@
     dc->in_receive = GNUNET_NO;
     dc->client = NULL;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will try to reconnect in 1s\n");
+  if (0 == dc->reconnect_backoff.rel_value)
+    dc->reconnect_backoff = GNUNET_TIME_UNIT_MILLISECONDS;
+  else
+    dc->reconnect_backoff = GNUNET_TIME_relative_min 
(GNUNET_TIME_relative_multiply (dc->reconnect_backoff, 2),
+                                                     
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10));
+  
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will try to reconnect in %s\n",
+             GNUNET_STRINGS_relative_time_to_string (dc->reconnect_backoff, 
GNUNET_YES));
   dc->task =
-      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_reconnect,
-                                    dc);
+    GNUNET_SCHEDULER_add_delayed (dc->reconnect_backoff, 
+                                 &do_reconnect,
+                                 dc);
 }
 
 

Modified: gnunet/src/fs/fs_search.c
===================================================================
--- gnunet/src/fs/fs_search.c   2012-10-05 07:53:54 UTC (rev 24187)
+++ gnunet/src/fs/fs_search.c   2012-10-05 07:55:28 UTC (rev 24188)
@@ -1158,8 +1158,15 @@
     GNUNET_CLIENT_disconnect (sc->client);
     sc->client = NULL;
   }
+  if (0 == sc->reconnect_backoff.rel_value)
+    sc->reconnect_backoff = GNUNET_TIME_UNIT_MILLISECONDS;
+  else
+    sc->reconnect_backoff = GNUNET_TIME_relative_min 
(GNUNET_TIME_relative_multiply (sc->reconnect_backoff, 2),
+                                                     
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10));
+
   sc->task =
-      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_reconnect,
+      GNUNET_SCHEDULER_add_delayed (sc->reconnect_backoff, 
+                                   &do_reconnect,
                                     sc);
 }
 




reply via email to

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