[systemd-devel] sd_bus_get_timeout returns absolute time despite what's documented

Lennart Poettering lennart at poettering.net
Mon Jan 9 12:02:05 UTC 2023


On Mo, 09.01.23 12:53, Lennart Poettering (lennart at poettering.net) wrote:

> https://www.freedesktop.org/software/systemd/man/sd_bus_get_fd.html#Description
>
>     Note that the returned time-value is absolute, based of
>     CLOCK_MONOTONIC and specified in microseconds. When converting
>     this value in order to pass it as third argument to poll() (which
>     expects relative milliseconds), care should be taken to convert to
>     a relative time and use a division that rounds up to ensure the
>     I/O polling operation doesn't sleep for shorter than necessary,
>     which might result in unintended busy looping (alternatively, use
>     ppoll(2) instead of plain poll(), which understands timeouts with
>     nano-second granularity).
>
> That's pretty explicit already, no?

This was fixed in 2021 btw, 25060a570c106cf5a14a3268bb0d38d9feb7fdab
i.e. systemd 250. Upgrade!

> (I mean, you have half a point, the first sentence of the explanation
> might people think this was a relative timeout, but we all read the
> full documentation, no, before actually using this API, no? ;-))
>
> Anyway, will prep a fix that rewords the first sentence to make this
> clearer right away.

https://github.com/systemd/systemd/pull/25985

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list