diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-09-05 14:20:06 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-09-05 14:20:24 +0200 |
commit | c1a9bb5df380beb363f56116bad6bd2e37df536a (patch) | |
tree | 0a9fc7d1db674c93c75c3493eefdf4aeb26d9609 /src/arm | |
parent | 0c9ffbeba9f19c0bde8ee9c6d3bea04f8867885c (diff) | |
download | gnunet-c1a9bb5df380beb363f56116bad6bd2e37df536a.tar.gz gnunet-c1a9bb5df380beb363f56116bad6bd2e37df536a.zip |
implement exponential back-off cool down for ARM process restarts
Diffstat (limited to 'src/arm')
-rw-r--r-- | src/arm/gnunet-service-arm.c | 16 |
1 files changed, 15 insertions, 1 deletions
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) | |||
1833 | statcode, | 1833 | statcode, |
1834 | GNUNET_STRINGS_relative_time_to_string (pos->backoff, | 1834 | GNUNET_STRINGS_relative_time_to_string (pos->backoff, |
1835 | GNUNET_YES)); | 1835 | GNUNET_YES)); |
1836 | /* schedule restart */ | 1836 | { |
1837 | /* Reduce backoff based on runtime of the process, | ||
1838 | so that there is a cool-down if a process actually | ||
1839 | runs for a while. */ | ||
1840 | struct GNUNET_TIME_Relative runtime; | ||
1841 | unsigned int minutes; | ||
1842 | |||
1843 | runtime = GNUNET_TIME_absolute_get_duration (pos->restart_at); | ||
1844 | minutes = runtime.rel_value_us / GNUNET_TIME_UNIT_MINUTES.rel_value_us; | ||
1845 | if (minutes > 31) | ||
1846 | pos->backoff = GNUNET_TIME_UNIT_ZERO; | ||
1847 | else | ||
1848 | pos->backoff.rel_value_us <<= minutes; | ||
1849 | } | ||
1850 | /* schedule restart */ | ||
1837 | pos->restart_at = GNUNET_TIME_relative_to_absolute (pos->backoff); | 1851 | pos->restart_at = GNUNET_TIME_relative_to_absolute (pos->backoff); |
1838 | pos->backoff = GNUNET_TIME_STD_BACKOFF (pos->backoff); | 1852 | pos->backoff = GNUNET_TIME_STD_BACKOFF (pos->backoff); |
1839 | if (NULL != child_restart_task) | 1853 | if (NULL != child_restart_task) |