Skip to content

Commit

Permalink
linux_udev: Retry poll() on EINTR
Browse files Browse the repository at this point in the history
The poll() syscall may temporarily fail when it is interrupted by a
signal; -1 is returned and errno is set to EINTR.

When this occurred, the udev event thread exited.

Instead, since this is a temporary failure, just try the call again.
<https://www.gnu.org/software/libc/manual/html_node/Interrupted-Primitives.html>

Signed-off-by: Romain Vimont <rom@rom1v.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  • Loading branch information
rom1v authored and jwrdegoede committed Nov 3, 2016
1 parent 09e75e9 commit 0a02d12
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion libusb/os/linux_udev.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ static void *linux_udev_event_thread_main(void *arg)


usbi_dbg("udev event thread entering."); usbi_dbg("udev event thread entering.");


while (poll(fds, 2, -1) >= 0) { while ((r = poll(fds, 2, -1)) >= 0 || errno == EINTR) {
if (r < 0) {
/* temporary failure */
continue;
}
if (fds[0].revents & POLLIN) { if (fds[0].revents & POLLIN) {
/* activity on control pipe, read the byte and exit */ /* activity on control pipe, read the byte and exit */
r = usbi_read(udev_control_pipe[0], &dummy, sizeof(dummy)); r = usbi_read(udev_control_pipe[0], &dummy, sizeof(dummy));
Expand Down
2 changes: 1 addition & 1 deletion libusb/version_nano.h
Original file line number Original file line Diff line number Diff line change
@@ -1 +1 @@
#define LIBUSB_NANO 11156 #define LIBUSB_NANO 11157

0 comments on commit 0a02d12

Please sign in to comment.