X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrdtool.c;h=b366a9c64166eeeae135f700b069e81578cac28a;hb=f1b5b8611d87a7904c31ae4b28ea47f11f3c38b9;hp=c948d1f803b282d0707b8daafa7d8571d61eee59;hpb=eaad4caa286149becaf08469cc4b08250d8beb2b;p=collectd.git diff --git a/src/rrdtool.c b/src/rrdtool.c index c948d1f8..b366a9c6 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -661,6 +661,14 @@ static int64_t rrd_get_random_variation (void) if (random_timeout <= 0) return (0); + /* Assure that "cache_timeout + random_variation" is never negative. */ + if (random_timeout > cache_timeout) + { + INFO ("rrdtool plugin: Adjusting \"RandomTimeout\" to %.3f seconds.", + CDTIME_T_TO_DOUBLE (cache_timeout)); + random_timeout = cache_timeout; + } + /* This seems a bit complicated, but "random_timeout" is likely larger than * RAND_MAX, so we can't simply use modulo here. */ dbl_timeout = CDTIME_T_TO_DOUBLE (random_timeout);