X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrdtool.c;h=b366a9c64166eeeae135f700b069e81578cac28a;hb=c4e824e456a30e1dc8f750a425472a0955f6b646;hp=ca5441a8d71ec093d1052cd16084307d59f2db69;hpb=e748b6f4faeb84f5393e362103d29a57600ec93d;p=collectd.git diff --git a/src/rrdtool.c b/src/rrdtool.c index ca5441a8..b366a9c6 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -305,7 +305,7 @@ static void *rrd_queue_thread (void __attribute__((unused)) *data) pthread_mutex_lock (&queue_lock); /* Wait for values to arrive */ - while (true) + while (42) { struct timespec ts_wait; @@ -344,7 +344,7 @@ static void *rrd_queue_thread (void __attribute__((unused)) *data) &ts_wait); if (status == ETIMEDOUT) break; - } /* while (true) */ + } /* while (42) */ /* XXX: If you need to lock both, cache_lock and queue_lock, at * the same time, ALWAYS lock `cache_lock' first! */ @@ -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); @@ -1159,12 +1167,12 @@ static int rrd_init (void) rrdcreate_config.heartbeat = 2 * rrdcreate_config.stepsize; if ((rrdcreate_config.heartbeat > 0) - && (rrdcreate_config.heartbeat < interval_g)) + && (rrdcreate_config.heartbeat < CDTIME_T_TO_TIME_T (interval_g))) WARNING ("rrdtool plugin: Your `heartbeat' is " "smaller than your `interval'. This will " "likely cause problems."); else if ((rrdcreate_config.stepsize > 0) - && (rrdcreate_config.stepsize < interval_g)) + && (rrdcreate_config.stepsize < CDTIME_T_TO_TIME_T (interval_g))) WARNING ("rrdtool plugin: Your `stepsize' is " "smaller than your `interval'. This will " "create needlessly big RRD-files.");