Repository navigation
linux-v4l2: udev thread stops instead of spinning on a poll error (#1280) - #1310
Merged
Merged
Conversation
Factors the udev thread's poll loop into udev_monitor_loop() with injectable fds (behaviour unchanged) and adds test_v4l2_udev_poll_error, which runs it on pipes reporting POLLHUP/POLLNVAL and expects it to stop.
#1280) A persistent POLLERR/POLLHUP/POLLNVAL on the udev monitor fd or the stop eventfd made poll() return at once forever while the loop continued: a busy spin. Log once and leave the loop; a poll() failure other than EINTR does the same. Shutdown still joins the (already finished) thread.
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.
Fixes #1280 (parent #1273).
Cause:
udev_event_threadinplugins/linux-v4l2/v4l2-udev.c.hpolled the udev netlink fd and the stop eventfd andcontinued whenever POLLIN was not set. A persistent POLLERR/POLLHUP/POLLNVAL makespoll()return immediately on every call, so the thread spun one core until shutdown.Fix: the loop is factored into
udev_monitor_loop(fd, stop_fd, stop, on_ready, ctx)(the thread passes the monitor fd, eventfd and a receive callback; normal path unchanged). If either fd reports POLLERR|POLLHUP|POLLNVAL, orpoll()fails with errno != EINTR, it logs one LOG_WARNING (which fd, revents/errno) and returns; the thread cleans up its udev objects and exits.v4l2_unref_udevstill signals andpthread_joins the finished thread. Hot-plug updates stop until restart.Tests (Tier 2, new):
test/cmocka/test_v4l2_udev_poll_error.cruns the real loop on pipes: monitor fd POLLHUP, monitor fd POLLNVAL, stop fd POLLHUP. Each must return within 50 ms in <= 2 iterations; the loop runs in a thread and is stopped via the stop event after the deadline, so a regression fails rather than hangs. No existing tests edited.run.sh --repeat 1 --tests test_v4l2: test_v4l2_udev_poll_error Failed, all 3 cases at line 72 (loop never returned); other v4l2 tests passed.Tiers 1/3/4: not applicable (C plugin bug fix, no Rust port involved).