From: Christian Grothoff Date: Mon, 9 Feb 2015 12:17:18 +0000 (+0000) Subject: -use backoff for reconnects X-Git-Tag: initial-import-from-subversion-38251~2381 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5b23ce75b0196174e5ea189314a0e7301e5c388b;p=oweals%2Fgnunet.git -use backoff for reconnects --- diff --git a/src/ats/ats_api_connectivity.c b/src/ats/ats_api_connectivity.c index f20743dc2..432f1ca35 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 19e769bd3..e81f0d394 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 1ed89e86e..fb6df4494 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c @@ -144,6 +144,11 @@ struct GNUNET_ATS_SchedulingHandle */ struct GNUNET_SCHEDULER_Task *task; + /** + * Reconnect backoff delay. + */ + struct GNUNET_TIME_Relative backoff; + /** * Size of the @e session_array. */ @@ -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,