X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrdtool.c;h=fad1e4b4455d5c6403df9ecc3a09522edade8981;hb=2354eda94fa44c8bcb8e39b24b117e7937110224;hp=4e34d6ad0aac1bbb93a5c537d58f07e7a559a49c;hpb=2c53e30ff65e5d5b09f39f8255a76c3e4a6f8947;p=collectd.git diff --git a/src/rrdtool.c b/src/rrdtool.c index 4e34d6ad..fad1e4b4 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -195,7 +195,7 @@ static int rra_get (char ***ret, const value_list_t *vl) span = rts[i]; if ((span / ss) < rrarows) - continue; + span = ss * rrarows; if (cdp_len == 0) cdp_len = 1; @@ -591,10 +591,10 @@ static int value_list_to_filename (char *buffer, int buffer_len, if (strlen (vl->type_instance) > 0) status = snprintf (buffer + offset, buffer_len - offset, - "%s-%s.rrd", ds->type, vl->type_instance); + "%s-%s.rrd", vl->type, vl->type_instance); else status = snprintf (buffer + offset, buffer_len - offset, - "%s.rrd", ds->type); + "%s.rrd", vl->type); if ((status < 1) || (status >= buffer_len - offset)) return (-1); offset += status; @@ -913,6 +913,11 @@ static int rrd_write (const data_set_t *ds, const value_list_t *vl) char values[512]; int status; + if (0 != strcmp (ds->type, vl->type)) { + ERROR ("rrdtool plugin: DS type does not match value list type"); + return -1; + } + if (value_list_to_filename (filename, sizeof (filename), ds, vl) != 0) return (-1); @@ -949,10 +954,13 @@ static int rrd_write (const data_set_t *ds, const value_list_t *vl) static int rrd_flush (const int timeout) { - if (cache == NULL) + pthread_mutex_lock (&cache_lock); + + if (cache == NULL) { + pthread_mutex_unlock (&cache_lock); return (0); + } - pthread_mutex_lock (&cache_lock); rrd_cache_flush (timeout); pthread_mutex_unlock (&cache_lock); return (0);