diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-09 12:17:18 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-09 12:17:18 +0000 |
commit | 5b23ce75b0196174e5ea189314a0e7301e5c388b (patch) | |
tree | 0695dc711df3bd67abcb9d245f6966e0d74ea1e1 /src/ats | |
parent | 16b3d36a08d5159a6d662b81146943060d08a149 (diff) |
-use backoff for reconnects
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/ats_api_connectivity.c | 7 | ||||
-rw-r--r-- | src/ats/ats_api_performance.c | 14 | ||||
-rw-r--r-- | src/ats/ats_api_scheduling.c | 9 |
3 files changed, 25 insertions, 5 deletions
diff --git a/src/ats/ats_api_connectivity.c b/src/ats/ats_api_connectivity.c index f20743dc2f..432f1ca359 100644 --- a/src/ats/ats_api_connectivity.c +++ b/src/ats/ats_api_connectivity.c @@ -78,6 +78,10 @@ struct GNUNET_ATS_ConnectivityHandle */ struct GNUNET_SCHEDULER_Task *task; + /** + * Reconnect backoff delay. + */ + struct GNUNET_TIME_Relative backoff; }; @@ -125,7 +129,8 @@ force_reconnect (struct GNUNET_ATS_ConnectivityHandle *ch) GNUNET_CLIENT_disconnect (ch->client); ch->client = NULL; } - ch->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, + ch->backoff = GNUNET_TIME_STD_BACKOFF (ch->backoff); + ch->task = GNUNET_SCHEDULER_add_delayed (ch->backoff, &reconnect_task, ch); } diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c index 19e769bd38..e81f0d3943 100644 --- a/src/ats/ats_api_performance.c +++ b/src/ats/ats_api_performance.c @@ -221,7 +221,12 @@ struct GNUNET_ATS_PerformanceHandle /** * Task to trigger reconnect. */ - struct GNUNET_SCHEDULER_Task * task; + struct GNUNET_SCHEDULER_Task *task; + + /** + * Reconnect backoff delay. + */ + struct GNUNET_TIME_Relative backoff; /** * Monitor request multiplexing @@ -609,6 +614,7 @@ process_ats_message (void *cls, GNUNET_break(0); goto reconnect; } + ph->backoff = GNUNET_TIME_UNIT_ZERO; GNUNET_CLIENT_receive (ph->client, &process_ats_message, ph, @@ -635,8 +641,10 @@ process_ats_message (void *cls, GNUNET_BANDWIDTH_value_init (0), NULL, 0); } - ph->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &reconnect_task, ph); + ph->backoff = GNUNET_TIME_STD_BACKOFF (ph->backoff); + ph->task = GNUNET_SCHEDULER_add_delayed (ph->backoff, + &reconnect_task, + ph); } diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index 1ed89e86e0..fb6df4494e 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c @@ -145,6 +145,11 @@ struct GNUNET_ATS_SchedulingHandle struct GNUNET_SCHEDULER_Task *task; /** + * Reconnect backoff delay. + */ + struct GNUNET_TIME_Relative backoff; + + /** * Size of the @e session_array. */ unsigned int session_array_size; @@ -200,7 +205,8 @@ force_reconnect (struct GNUNET_ATS_SchedulingHandle *sh) NULL, NULL, NULL, GNUNET_BANDWIDTH_ZERO, GNUNET_BANDWIDTH_ZERO); - sh->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, + sh->backoff = GNUNET_TIME_STD_BACKOFF (sh->backoff); + sh->task = GNUNET_SCHEDULER_add_delayed (sh->backoff, &reconnect_task, sh); } @@ -432,6 +438,7 @@ process_ats_address_suggestion_message (void *cls, GNUNET_break (0); return; } + sh->backoff = GNUNET_TIME_UNIT_ZERO; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS suggests address slot %u for peer `%s' using plugin %s\n", ar->slot, |