Merge branch 'collectd-4.3' into collectd-4.4
[collectd.git] / src / rrdtool.c
index 161037c..3b2c54f 100644 (file)
@@ -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;
@@ -947,6 +947,20 @@ static int rrd_write (const data_set_t *ds, const value_list_t *vl)
        return (status);
 } /* int rrd_write */
 
+static int rrd_flush (const int timeout)
+{
+       pthread_mutex_lock (&cache_lock);
+
+       if (cache == NULL) {
+               pthread_mutex_unlock (&cache_lock);
+               return (0);
+       }
+
+       rrd_cache_flush (timeout);
+       pthread_mutex_unlock (&cache_lock);
+       return (0);
+} /* int rrd_flush */
+
 static int rrd_config (const char *key, const char *value)
 {
        if (strcasecmp ("CacheTimeout", key) == 0)
@@ -1152,5 +1166,6 @@ void module_register (void)
                        config_keys, config_keys_num);
        plugin_register_init ("rrdtool", rrd_init);
        plugin_register_write ("rrdtool", rrd_write);
+       plugin_register_flush ("rrdtool", rrd_flush);
        plugin_register_shutdown ("rrdtool", rrd_shutdown);
 }