emersion / xdg-desktop-portal-wlr

xdg-desktop-portal backend for wlroots
MIT License
579 stars 53 forks source link

Fix bug in sd-bus polling #282

Closed cillian64 closed 7 months ago

cillian64 commented 10 months ago

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

name-snrl commented 8 months ago

As I said in #281, this PR completely solves the random startup delay for me. I hope it will be merged in the near future

emersion commented 7 months ago

LGTM apart from this nit.

cillian64 commented 7 months ago

Thanks for the review!