udev-monitor: make the monitor fd non-blocking#19
Open
lwhsu wants to merge 1 commit into
Open
Conversation
systemd's libudev documents that the monitor socket is non-blocking by default: https://github.com/systemd/systemd/blob/v261/src/libudev/libudev-monitor.c#L228-L231 It also creates the monitor socket with SOCK_NONBLOCK: https://github.com/systemd/systemd/blob/v261/src/libsystemd/sd-device/device-monitor.c#L179-L183 libudev-devd currently uses a blocking pipe. Once all pending events have been consumed, another call to udev_monitor_receive_device() blocks instead of returning NULL with EAGAIN. This was observed in KWin, where display hotplug handling stalled after disconnecting and reconnecting an external display in a KDE/Wayland session. Set O_NONBLOCK on the read end returned by udev_monitor_get_fd(). Keep the internal write end blocking to preserve the current producer and backpressure behavior. Sponsored by: The FreeBSD Foundation
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
systemd's libudev documents that the monitor socket is non-blocking by default:
https://github.com/systemd/systemd/blob/v261/src/libudev/libudev-monitor.c#L228-L231
It also creates the monitor socket with SOCK_NONBLOCK:
https://github.com/systemd/systemd/blob/v261/src/libsystemd/sd-device/device-monitor.c#L179-L183
libudev-devd currently uses a blocking pipe. Once all pending events have been consumed, another call to udev_monitor_receive_device() blocks instead of returning NULL with EAGAIN.
This was observed in KWin, where display hotplug handling stalled after disconnecting and reconnecting an external display in a KDE/Wayland session.
Set O_NONBLOCK on the read end returned by udev_monitor_get_fd(). Keep the internal write end blocking to preserve the current producer and backpressure behavior.
Sponsored by: The FreeBSD Foundation