diff options
Diffstat (limited to 'libusb/io.c')
-rw-r--r-- | libusb/io.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libusb/io.c b/libusb/io.c index 9cf38f8..07010c4 100644 --- a/libusb/io.c +++ b/libusb/io.c @@ -2051,8 +2051,27 @@ redo_poll: /* another thread wanted to interrupt event handling, and it succeeded! * handle any other events that cropped up at the same time, and * simply return */ + ssize_t ret; + unsigned char dummy; + unsigned int ru; + usbi_dbg("caught a fish on the control pipe"); + /* read the dummy data from the control pipe unless someone is closing + * a device */ + usbi_mutex_lock(&ctx->pollfd_modify_lock); + ru = ctx->pollfd_modify; + usbi_mutex_unlock(&ctx->pollfd_modify_lock); + if (!ru) { + ret = usbi_read(ctx->ctrl_pipe[0], &dummy, sizeof(dummy)); + if (ret != sizeof(dummy)) { + usbi_err(ctx, "control pipe read error %d err=%d", + ret, errno); + r = LIBUSB_ERROR_OTHER; + goto handled; + } + } + if (0 == --r) goto handled; } |