From: Lennart Poettering Date: Fri, 5 Sep 2025 12:22:07 +0000 (+0200) Subject: sd-varlink: add api for resetting timeout to default X-Git-Tag: v259-rc1~511^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04e2cb892878574b4e5715a22c2901c34762cff6;p=thirdparty%2Fsystemd.git sd-varlink: add api for resetting timeout to default We currently don't expose the literal default time-out as API. Let's at least provide users with a way to reset the time-out to the default. --- diff --git a/man/rules/meson.build b/man/rules/meson.build index 62841837560..50432f0b8d8 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -917,6 +917,7 @@ manpages = [ ['sd_varlink_push_fd', '3', ['sd_varlink_push_dup_fd'], ''], ['sd_varlink_send', '3', ['sd_varlink_sendb', 'sd_varlink_sendbo'], ''], ['sd_varlink_set_description', '3', ['sd_varlink_get_description'], ''], + ['sd_varlink_set_relative_timeout', '3', [], ''], ['sd_watchdog_enabled', '3', [], ''], ['shutdown', '8', [], ''], ['smbios-type-11', '7', [], ''], diff --git a/man/sd_varlink_set_relative_timeout.xml b/man/sd_varlink_set_relative_timeout.xml new file mode 100644 index 00000000000..06c87a60502 --- /dev/null +++ b/man/sd_varlink_set_relative_timeout.xml @@ -0,0 +1,88 @@ + + + + + + + + sd_varlink_set_relative_timeout + systemd + + + + sd_varlink_set_relative_timeout + 3 + + + + sd_varlink_set_relative_timeout + + Set method call time-out + + + + + #include <systemd/sd-varlink.h> + + + int sd_varlink_set_relative_timeout + sd_varlink *link + uint64_t usec + + + + + + + Description + + sd_varlink_set_relative_timeout() sets the relative timeout in µs to enforce + on Varlink method calls. A default time-out of 45s (currently) applies, which may be changed with this + call. Set to UINT64_MAX to disable the time-out, and to 0 to revert to revert back + to the default time-out. The time-out begins whenever a method call is started, and if no response is + received by the time the time-out elapses a synthetic io.systemd.TimedOut error is + raised as client-generated reply to the method call. + + This call is particularly useful for method calls issued via + sd_varlink_observe() that shall remain open continously for a long time. + + + + Return Value + + On success, sd_varlink_set_relative_timeout() returns a non-negative integer. On + failure, it returns a negative errno-style error code. + + + Errors + + Returned errors may indicate the following problems: + + + + -EINVAL + + An argument is invalid. + + + + + + + + + History + sd_varlink_set_relative_timeout() was added in version 257. + + + + See Also + + + systemd1 + sd-varlink3 + + + + diff --git a/src/libsystemd/sd-varlink/sd-varlink.c b/src/libsystemd/sd-varlink/sd-varlink.c index 1666162e890..ee2272f9433 100644 --- a/src/libsystemd/sd-varlink/sd-varlink.c +++ b/src/libsystemd/sd-varlink/sd-varlink.c @@ -2911,9 +2911,9 @@ _public_ int sd_varlink_get_peer_pidfd(sd_varlink *v) { _public_ int sd_varlink_set_relative_timeout(sd_varlink *v, uint64_t timeout) { assert_return(v, -EINVAL); - assert_return(timeout > 0, -EINVAL); - v->timeout = timeout; + /* If set to 0, reset to default value */ + v->timeout = timeout == 0 ? VARLINK_DEFAULT_TIMEOUT_USEC : timeout; return 0; }