aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-10-05 07:55:28 +0000
committerChristian Grothoff <christian@grothoff.org>2012-10-05 07:55:28 +0000
commit17276ed4b30d150d540e8ec270ccf96be6f5ee29 (patch)
tree57d18271fec19876c4842258d96af521ffa3d5bb /src/fs
parent07eb9c1e6c98769306b16a31f7ad9d3b454b0e2e (diff)
downloadgnunet-17276ed4b30d150d540e8ec270ccf96be6f5ee29.tar.gz
gnunet-17276ed4b30d150d540e8ec270ccf96be6f5ee29.zip
-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
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/fs_api.h10
-rw-r--r--src/fs/fs_download.c14
-rw-r--r--src/fs/fs_search.c9
3 files changed, 29 insertions, 4 deletions
diff --git a/src/fs/fs_api.h b/src/fs/fs_api.h
index 9325c6023..d4b7aa202 100644
--- a/src/fs/fs_api.h
+++ b/src/fs/fs_api.h
@@ -1536,6 +1536,11 @@ struct GNUNET_FS_SearchContext
1536 struct GNUNET_TIME_Absolute start_time; 1536 struct GNUNET_TIME_Absolute start_time;
1537 1537
1538 /** 1538 /**
1539 * How long to wait before we try to reconnect to FS service?
1540 */
1541 struct GNUNET_TIME_Relative reconnect_backoff;
1542
1543 /**
1539 * ID of a task that is using this struct and that must be cancelled 1544 * ID of a task that is using this struct and that must be cancelled
1540 * when the search is being stopped (if not 1545 * when the search is being stopped (if not
1541 * GNUNET_SCHEDULER_NO_TASK). Used for the task that adds some 1546 * GNUNET_SCHEDULER_NO_TASK). Used for the task that adds some
@@ -1900,6 +1905,11 @@ struct GNUNET_FS_DownloadContext
1900 struct GNUNET_TIME_Absolute start_time; 1905 struct GNUNET_TIME_Absolute start_time;
1901 1906
1902 /** 1907 /**
1908 * How long to wait before we try to reconnect to FS service?
1909 */
1910 struct GNUNET_TIME_Relative reconnect_backoff;
1911
1912 /**
1903 * Desired level of anonymity. 1913 * Desired level of anonymity.
1904 */ 1914 */
1905 uint32_t anonymity; 1915 uint32_t anonymity;
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index 3434a9553..e9839cc2d 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -1436,10 +1436,18 @@ try_reconnect (struct GNUNET_FS_DownloadContext *dc)
1436 dc->in_receive = GNUNET_NO; 1436 dc->in_receive = GNUNET_NO;
1437 dc->client = NULL; 1437 dc->client = NULL;
1438 } 1438 }
1439 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will try to reconnect in 1s\n"); 1439 if (0 == dc->reconnect_backoff.rel_value)
1440 dc->reconnect_backoff = GNUNET_TIME_UNIT_MILLISECONDS;
1441 else
1442 dc->reconnect_backoff = GNUNET_TIME_relative_min (GNUNET_TIME_relative_multiply (dc->reconnect_backoff, 2),
1443 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10));
1444
1445 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will try to reconnect in %s\n",
1446 GNUNET_STRINGS_relative_time_to_string (dc->reconnect_backoff, GNUNET_YES));
1440 dc->task = 1447 dc->task =
1441 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_reconnect, 1448 GNUNET_SCHEDULER_add_delayed (dc->reconnect_backoff,
1442 dc); 1449 &do_reconnect,
1450 dc);
1443} 1451}
1444 1452
1445 1453
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index 3b28c9a58..a5b2d3643 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -1158,8 +1158,15 @@ try_reconnect (struct GNUNET_FS_SearchContext *sc)
1158 GNUNET_CLIENT_disconnect (sc->client); 1158 GNUNET_CLIENT_disconnect (sc->client);
1159 sc->client = NULL; 1159 sc->client = NULL;
1160 } 1160 }
1161 if (0 == sc->reconnect_backoff.rel_value)
1162 sc->reconnect_backoff = GNUNET_TIME_UNIT_MILLISECONDS;
1163 else
1164 sc->reconnect_backoff = GNUNET_TIME_relative_min (GNUNET_TIME_relative_multiply (sc->reconnect_backoff, 2),
1165 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10));
1166
1161 sc->task = 1167 sc->task =
1162 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_reconnect, 1168 GNUNET_SCHEDULER_add_delayed (sc->reconnect_backoff,
1169 &do_reconnect,
1163 sc); 1170 sc);
1164} 1171}
1165 1172