]> git.itanic.dy.fi Git - rrdd/blobdiff - rrdtool.c
rrdtool: Stop update times from drifting
[rrdd] / rrdtool.c
index c92dee186c56c9a28951d10aa089ab47f0816419..6748c39af5c937dced74c00f1fe6c1f128074bb4 100644 (file)
--- a/rrdtool.c
+++ b/rrdtool.c
@@ -315,7 +315,13 @@ static int do_rrdtool_update_data(struct rrd_database *rrd)
 
 int rrdtool_update_data(struct rrd_database *rrd)
 {
-       rrd->last_update = time(0);
+       time_t now = time(0);
+
+       /*
+        * This will put our last update slightly into past, but
+        * ensures our update interval will not drift over time.
+        */
+       rrd->last_update = now - now % rrd->interval;
 
        return queue_work(WORK_PRIORITY_HIGH, "rrdtool_update_data",
                        (work_fn_t *)do_rrdtool_update_data, rrd);