summaryrefslogtreecommitdiff
path: root/libusb/core.c
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2014-08-25 23:26:52 -0700
committerChris Dickens <christopher.a.dickens@gmail.com>2014-08-27 01:50:09 -0700
commit9a9ef3ec2b9c691609ec9f8b82ac4436a662df18 (patch)
tree901f35fd2fbba3acc711229544d613ff4a48db1b /libusb/core.c
parenta3a4806d494b8ff3dd213d5eb408b657bcdd47f0 (diff)
downloadlibusb-9a9ef3ec2b9c691609ec9f8b82ac4436a662df18.tar.gz
core: Only interrupt event handlers as necessary during libusb_open()
The current behavior of libusb_open() unconditionally interrupts any event handlers via usbi_fd_notification(). However, not all backends, namely Win/WinCE, make changes to the pollfd list during a device open. This change adds a new CAP for backends (HAS_POLLABLE_DEVICE_FD), and libusb_open() will only call usbi_fd_notification() if the backend declares this capability. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Diffstat (limited to 'libusb/core.c')
-rw-r--r--libusb/core.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/libusb/core.c b/libusb/core.c
index f3d7ece..1b74493 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -1125,13 +1125,15 @@ int API_EXPORTED libusb_open(libusb_device *dev,
usbi_mutex_unlock(&ctx->open_devs_lock);
*handle = _handle;
- /* At this point, we want to interrupt any existing event handlers so
- * that they realise the addition of the new device's poll fd. One
- * example when this is desirable is if the user is running a separate
- * dedicated libusb events handling thread, which is running with a long
- * or infinite timeout. We want to interrupt that iteration of the loop,
- * so that it picks up the new fd, and then continues. */
- usbi_fd_notification(ctx);
+ if (usbi_backend->caps & USBI_CAP_HAS_POLLABLE_DEVICE_FD) {
+ /* At this point, we want to interrupt any existing event handlers so
+ * that they realise the addition of the new device's poll fd. One
+ * example when this is desirable is if the user is running a separate
+ * dedicated libusb events handling thread, which is running with a long
+ * or infinite timeout. We want to interrupt that iteration of the loop,
+ * so that it picks up the new fd, and then continues. */
+ usbi_fd_notification(ctx);
+ }
return 0;
}