]> git.proxmox.com Git - pve-cluster.git/blobdiff - data/src/status.c
fix #1559: pmxcfs: add missing lock when dumping .rrd
[pve-cluster.git] / data / src / status.c
index 14a40c4801372b4529b77169855a688d7e6ac20b..3c16a8bc9e1c712b15614cbc68fb0654c6047330 100644 (file)
@@ -1075,10 +1075,13 @@ void
 cfs_rrd_dump(GString *str)
 {
        time_t ctime;
-       time(&ctime);
 
+       g_mutex_lock (&mutex);
+
+       time(&ctime);
        if (rrd_dump_buf && (ctime - rrd_dump_last) < 2) {
                g_string_assign(str, rrd_dump_buf);
+               g_mutex_unlock (&mutex);
                return;
        }
 
@@ -1107,6 +1110,8 @@ cfs_rrd_dump(GString *str)
        if (rrd_dump_buf)
                g_free(rrd_dump_buf);
        rrd_dump_buf = g_strdup(str->str);
+
+       g_mutex_unlock (&mutex);
 }
 
 static gboolean