core: Add new flag to record when a new poll fd is added
authorChris Dickens <christopher.a.dickens@gmail.com>
Tue, 18 Nov 2014 07:53:12 +0000 (23:53 -0800)
committerChris Dickens <chris.dickens@hp.com>
Fri, 19 Dec 2014 19:20:11 +0000 (11:20 -0800)
This flag will be useful in a subsequent commit that further
consolidates event handling.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/core.c
libusb/libusbi.h
libusb/version_nano.h

index 32db2a6..13100da 100644 (file)
@@ -1215,6 +1215,12 @@ int usbi_clear_event(struct libusb_context *ctx)
  */
 void usbi_fd_notification(struct libusb_context *ctx)
 {
+       /* record that there is a new poll fd */
+       usbi_mutex_lock(&ctx->event_data_lock);
+       ctx->fd_notify = 1;
+       usbi_mutex_unlock(&ctx->event_data_lock);
+
+       /* signal the event pipe to interrupt event handlers */
        usbi_signal_event(ctx);
 }
 
index ebcc0d3..cb24cf9 100644 (file)
@@ -294,6 +294,10 @@ struct libusb_context {
         * in order to safely close a device. Protected by event_data_lock. */
        unsigned int device_close;
 
+       /* A flag that is set when we want to interrupt event handling, in order to
+        * pick up a new fd for polling. Protected by event_data_lock. */
+       unsigned int fd_notify;
+
        /* used to wait for event completion in threads other than the one that is
         * event handling */
        usbi_mutex_t event_waiters_lock;
index 73d2ed1..9624091 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10936
+#define LIBUSB_NANO 10937