X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Futils_cache.c;h=20b12375d8ebfc159de13f520c46b89052ae1e97;hb=83077c18c3e78739c2d2d18debf99875944eaa72;hp=05db70c888c220a897d52d417146e546a38b1cd0;hpb=16a2994a13565e3f444bb6dfddce54cbdcdf1e4a;p=collectd.git diff --git a/src/utils_cache.c b/src/utils_cache.c index 05db70c8..20b12375 100644 --- a/src/utils_cache.c +++ b/src/utils_cache.c @@ -44,7 +44,7 @@ typedef struct cache_entry_s cdtime_t last_update; /* Interval in which the data is collected * (for purding old entries) */ - int interval; + cdtime_t interval; int state; int hits; @@ -175,7 +175,7 @@ static int uc_send_notification (const char *name) } /* Check if the entry has been updated in the meantime */ - if ((n.time - ce->last_update) < (2 * ce->interval)) + if ((n.time - ce->last_update) < (timeout_g * ce->interval)) { ce->state = STATE_OKAY; pthread_mutex_unlock (&cache_lock); @@ -258,7 +258,7 @@ static int uc_insert (const data_set_t *ds, const value_list_t *vl, ce->values_gauge[i] = NAN; if (vl->interval > 0) ce->values_gauge[i] = ((double) vl->values[i].absolute) - / ((double) vl->interval); + / CDTIME_T_TO_DOUBLE (vl->interval); ce->values_raw[i].absolute = vl->values[i].absolute; break; @@ -319,8 +319,7 @@ int uc_check_timeout (void) while (c_avl_iterator_next (iter, (void *) &key, (void *) &ce) == 0) { /* If entry has not been updated, add to `keys' array */ - /* FIXME: Remove macro once "ce->interval" is of type cdtime_t. */ - if ((now - ce->last_update) >= TIME_T_TO_CDTIME_T (timeout_g * ce->interval)) + if ((now - ce->last_update) >= (ce->interval * timeout_g)) { char **tmp;