From 91f986ec9969d8a16502fa1253ee1a7f9bd3439b Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Tue, 16 Aug 2022 21:30:02 -0400 Subject: [PATCH] linux-v4l2: Check udev fd events udev_event_thread calls poll with two fds: the udev fd, and an eventfd used for shutdown. On FreeBSD we were hanging on shutdown in udev_monitor_receive_device after receiving the eventfd event. Now, if the udev fd reports no events skip the udev_monitor_receive_device call. At shutdown the loop will exit via os_event_try(). --- plugins/linux-v4l2/v4l2-udev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/linux-v4l2/v4l2-udev.c b/plugins/linux-v4l2/v4l2-udev.c index 67a50af86..4dbd692c6 100644 --- a/plugins/linux-v4l2/v4l2-udev.c +++ b/plugins/linux-v4l2/v4l2-udev.c @@ -133,12 +133,16 @@ static void *udev_event_thread(void *vptr) fds[0].fd = fd; fds[0].events = POLLIN; + fds[0].revents = 0; fds[1].fd = udev_event_fd; fds[1].events = POLLIN; if (poll(fds, 2, 1000) <= 0) continue; + if (!fds[0].revents & POLLIN) + continue; + dev = udev_monitor_receive_device(mon); if (!dev) continue;