CDTIME_T_TO_DOUBLE(timeout));
now = cdtime();
- timeout = TIME_T_TO_CDTIME_T(timeout);
/* Build a list of entries to be flushed */
iter = c_avl_get_iterator(cache);
} /* int rrd_cache_flush_identifier */
static int64_t rrd_get_random_variation(void) {
- long min;
- long max;
-
if (random_timeout == 0)
return (0);
random_timeout = cache_timeout;
}
- max = (long)(random_timeout / 2);
- min = max - ((long)random_timeout);
-
- return ((int64_t)cdrand_range(min, max));
+ return (int64_t)cdrand_range(-random_timeout, random_timeout);
} /* int64_t rrd_get_random_variation */
static int rrd_cache_insert(const char *filename, const char *value,
if ((cache_timeout > 0) &&
((cdtime() - cache_flush_last) > cache_flush_timeout))
- rrd_cache_flush(cache_flush_timeout);
+ rrd_cache_flush(cache_timeout);
pthread_mutex_unlock(&cache_lock);
"be greater than 0.\n");
return (1);
}
- cache_flush_timeout = tmp;
+ cache_flush_timeout = TIME_T_TO_CDTIME_T(tmp);
} else if (strcasecmp("DataDir", key) == 0) {
char *tmp;
size_t len;
cache_flush_last = cdtime();
if (cache_timeout == 0) {
cache_flush_timeout = 0;
- } else if (cache_flush_timeout < cache_timeout)
+ } else if (cache_flush_timeout < cache_timeout) {
+ INFO("rrdtool plugin: \"CacheFlush %u\" is less than \"CacheTimeout %u\". "
+ "Ajusting \"CacheFlush\" to %u seconds.",
+ (unsigned int)CDTIME_T_TO_TIME_T(cache_flush_timeout),
+ (unsigned int)CDTIME_T_TO_TIME_T(cache_timeout),
+ (unsigned int)CDTIME_T_TO_TIME_T(cache_timeout * 10));
cache_flush_timeout = 10 * cache_timeout;
+ }
pthread_mutex_unlock(&cache_lock);