cillian64 and emersion Fix bug in sd-bus polling
b5f3878 Nov 21, 2023
Fix bug in sd-bus polling
sd-bus requires that `sd_bus_get_fd`, `sd_bus_get_events`, and
`sd_bus_get_timeout` are called for every invocation of `poll`, and the
returned FD, events, and timeout used.  In particular, sd-bus may return
`events=0` and `timeout=0` if it already has dbus messages to process in
its receive queue.

xdpw currently doesn't call `sd_bus_get_events` or `sd_bus_get_timeout`
at all.  This can result in the situation where xdpw goes into a `poll`
with no timeout and a message in sd-bus' receive queue is never handled
until another dbus message arrives.  I have a case where this ignored
messages causes xdg-desktop-portal to hang.

This commit changes the polling code to match sd-bus' requirements.

Fixes #281
b5f3878