evdev: Fix select() call

It's not guaranteed that the eventfd is smaller than the monitor fd,
because fds are not always monotonically allocated. To select()
correctly in all cases, use the max between the monitor fd and eventfd.
This commit is contained in:
Léo Lam 2018-02-04 22:45:28 +01:00
parent 51d3de6787
commit 9a3705f82d

View File

@ -72,7 +72,7 @@ static void HotplugThreadFunc()
FD_SET(monitor_fd, &fds);
FD_SET(s_wakeup_eventfd, &fds);
int ret = select(monitor_fd + 1, &fds, nullptr, nullptr, nullptr);
int ret = select(std::max(monitor_fd, s_wakeup_eventfd) + 1, &fds, nullptr, nullptr, nullptr);
if (ret < 1 || !FD_ISSET(monitor_fd, &fds))
continue;