]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commit
Allow to select locking mechanism (#1207)
authorEnrico Scholz <github@ensc.de>
Thu, 2 Mar 2023 16:00:25 +0000 (17:00 +0100)
committerGitHub <noreply@github.com>
Thu, 2 Mar 2023 16:00:25 +0000 (17:00 +0100)
commitf71039b4114de3784969de01612f9f0c5a68089f
tree5062bd85235f06e62a5873e0fbcafe3a2327260b
parentd897a14493d80438a311419e14d766df7a0ef90c
Allow to select locking mechanism (#1207)

* rrd: add _rrd_lock_xxx() helper functions and constants

This adds two sets of constants: these used in 'extra_flags' in various
parts of the extended api (e.g. rrd_updatex_r()), and these used within
rrd_open().

There are implemented some helper functions which help to parse command
line strings and environment variables, and to convert these two sets
of constants.

* rrd_update: pass custom RRD_LOCK_xxx flags to rrd_open()

* rrd_update: add '--locking' cli option

* rrd_open: handle RRD_LOCK_DEFAULT

When rrd_open() was called with RRD_LOCK_DEFAULT, read the locking
setup from $RRD_LOCKING environment.

* rrd_open: implement other locking methods

Allow locking to wait and make it possible to bypass locking
completely.

With this patch it is e.g. expected:

| $ RRD_LOCKING=none strace -e fcntl rrdupdate --locking block x N:1
| fcntl(3, F_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0

Other values for RRD_LOCKING and --locking give

 | RRD_LOCKING=... | --locking ... | fcntl()  |
 |-----------------|---------------|----------|
 | *               |               | F_SETLK  |
 | *               | block         | F_SETLKW |
 | *               | try           | F_SETLK  |
 | *               | none          |          |
 | block           |               | F_SETLKW |
 | try             |               | F_SETLK  |
 | none            |               |          |

* doc: document --locking + $RRD_LOCKING

Signed-off-by: Enrico Scholz <enrico.scholz@ensc.de>
CHANGES
doc/rrdtool.pod
doc/rrdupdate.pod
src/rrd.h
src/rrd_open.c
src/rrd_tool.h
src/rrd_update.c
src/rrdupdate.c