From f5795bfa0e5d9e2ccd1e031d02269f041101aca7 Mon Sep 17 00:00:00 2001 From: Chris Dickens Date: Mon, 17 Nov 2014 23:53:12 -0800 Subject: core: Add new flag to record when a new poll fd is added This flag will be useful in a subsequent commit that further consolidates event handling. Signed-off-by: Chris Dickens --- libusb/core.c | 6 ++++++ libusb/libusbi.h | 4 ++++ libusb/version_nano.h | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libusb/core.c b/libusb/core.c index 32db2a6..13100da 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -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); } diff --git a/libusb/libusbi.h b/libusb/libusbi.h index ebcc0d3..cb24cf9 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -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; diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 73d2ed1..9624091 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10936 +#define LIBUSB_NANO 10937 -- cgit v1.2.3