]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
fix: update rrd_rwlock() call in librados code 1301/head
authorEnrico Scholz <enrico.scholz@ensc.de>
Sun, 21 Dec 2025 10:51:18 +0000 (11:51 +0100)
committerEnrico Scholz <enrico.scholz@ensc.de>
Sun, 21 Dec 2025 11:20:56 +0000 (12:20 +0100)
The locking API has been changed; update corresponding calls.

Warn when unsupported blocking locks are requested.

Fixes #1298

Signed-off-by: Enrico Scholz <enrico.scholz@ensc.de>
src/rrd_open.c

index fca4ecee38bcf49b027675697e0e4c30c12155aa..47c19100de22527abc2a1e1f659898a0882e1b1a 100644 (file)
@@ -227,12 +227,20 @@ rrd_file_t *rrd_open(
         if (rrd_file->rados == NULL)
             goto out_free;
 
-        if (rdwr & RRD_LOCK) {
-            /* Note: rados read lock is not implemented.  See rrd_lock(). */
-            if (rrd_rwlock(rrd_file, rdwr & RRD_READWRITE) != 0) {
-                rrd_set_error("could not lock RRD");
-                goto out_close;
+        if ((rdwr & RRD_LOCK_MASK) == RRD_LOCK_BLOCK) {
+            static int warned = 0;
+            if (!warned) {
+                fprintf(stderr, "blocking locks not supported by rados; falling back to non-blocking\n");
+                warned = 1;
             }
+            rdwr &= ~RRD_LOCK_MASK;
+            rdwr |= RRD_LOCK_TRY;
+        }
+
+        /* Note: rados read lock is not implemented.  See rrd_lock(). */
+        if (rrd_rwlock(rrd_file, rdwr & RRD_READWRITE, rdwr & RRD_LOCK_MASK) != 0) {
+            rrd_set_error("could not lock RRD");
+            goto out_close;
         }
 
         if (rdwr & RRD_CREAT)