From: Christian Grothoff Date: Tue, 5 Sep 2017 12:20:06 +0000 (+0200) Subject: implement exponential back-off cool down for ARM process restarts X-Git-Tag: gnunet-0.11.0rc0~125^2 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c1a9bb5df380beb363f56116bad6bd2e37df536a;p=oweals%2Fgnunet.git implement exponential back-off cool down for ARM process restarts --- diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index 19088c5cb..2db2ba0d1 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c @@ -1833,7 +1833,21 @@ maint_child_death (void *cls) statcode, GNUNET_STRINGS_relative_time_to_string (pos->backoff, GNUNET_YES)); - /* schedule restart */ + { + /* Reduce backoff based on runtime of the process, + so that there is a cool-down if a process actually + runs for a while. */ + struct GNUNET_TIME_Relative runtime; + unsigned int minutes; + + runtime = GNUNET_TIME_absolute_get_duration (pos->restart_at); + minutes = runtime.rel_value_us / GNUNET_TIME_UNIT_MINUTES.rel_value_us; + if (minutes > 31) + pos->backoff = GNUNET_TIME_UNIT_ZERO; + else + pos->backoff.rel_value_us <<= minutes; + } + /* schedule restart */ pos->restart_at = GNUNET_TIME_relative_to_absolute (pos->backoff); pos->backoff = GNUNET_TIME_STD_BACKOFF (pos->backoff); if (NULL != child_restart_task)