From: Enrico Scholz Date: Sun, 21 Dec 2025 10:51:18 +0000 (+0100) Subject: fix: update rrd_rwlock() call in librados code X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ee2ee5a8bcde42f386acf40012f8cede2113cf4;p=thirdparty%2Frrdtool-1.x.git fix: update rrd_rwlock() call in librados code The locking API has been changed; update corresponding calls. Warn when unsupported blocking locks are requested. Fixes #1298 Signed-off-by: Enrico Scholz --- diff --git a/src/rrd_open.c b/src/rrd_open.c index fca4ecee..47c19100 100644 --- a/src/rrd_open.c +++ b/src/rrd_open.c @@ -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)