浏览代码

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().
Ed Maste 3 年之前
父节点
当前提交
91f986ec99
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      plugins/linux-v4l2/v4l2-udev.c

+ 4 - 0
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;