summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2014-11-17 23:53:08 -0800
committerChris Dickens <chris.dickens@hp.com>2014-12-19 11:12:48 -0800
commit0e62e5cf34cd02e811157ecb4c6725f2b940a136 (patch)
treec988212fe5dfc2800588497fd7f2ebbeabcfa9e8
parentc57953cfb3c8ecd4c51d34b7a2982713925530cd (diff)
downloadlibusb-0e62e5cf34cd02e811157ecb4c6725f2b940a136.tar.gz
core: Add new lock to protect internal context event data
This lock will be used in subsequent changes that will consolidate all different event sources (i.e. device close, fd notification, hotplug message) into a single event. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-rw-r--r--libusb/io.c3
-rw-r--r--libusb/libusbi.h3
-rw-r--r--libusb/version_nano.h2
3 files changed, 7 insertions, 1 deletions
diff --git a/libusb/io.c b/libusb/io.c
index 7700e8c..2b3c755 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -1114,6 +1114,7 @@ int usbi_io_init(struct libusb_context *ctx)
usbi_mutex_init(&ctx->pollfds_lock, NULL);
usbi_mutex_init(&ctx->device_close_lock, NULL);
usbi_mutex_init_recursive(&ctx->events_lock, NULL);
+ usbi_mutex_init(&ctx->event_data_lock, NULL);
usbi_mutex_init(&ctx->event_waiters_lock, NULL);
usbi_cond_init(&ctx->event_waiters_cond, NULL);
list_init(&ctx->flying_transfers);
@@ -1175,6 +1176,7 @@ err:
usbi_mutex_destroy(&ctx->pollfds_lock);
usbi_mutex_destroy(&ctx->device_close_lock);
usbi_mutex_destroy(&ctx->events_lock);
+ usbi_mutex_destroy(&ctx->event_data_lock);
usbi_mutex_destroy(&ctx->event_waiters_lock);
usbi_cond_destroy(&ctx->event_waiters_cond);
return r;
@@ -1198,6 +1200,7 @@ void usbi_io_exit(struct libusb_context *ctx)
usbi_mutex_destroy(&ctx->pollfds_lock);
usbi_mutex_destroy(&ctx->device_close_lock);
usbi_mutex_destroy(&ctx->events_lock);
+ usbi_mutex_destroy(&ctx->event_data_lock);
usbi_mutex_destroy(&ctx->event_waiters_lock);
usbi_cond_destroy(&ctx->event_waiters_cond);
if (ctx->pollfds)
diff --git a/libusb/libusbi.h b/libusb/libusbi.h
index ffca4a3..b1c056e 100644
--- a/libusb/libusbi.h
+++ b/libusb/libusbi.h
@@ -293,6 +293,9 @@ struct libusb_context {
/* used to see if there is an active thread doing event handling */
int event_handler_active;
+ /* A lock to protect internal context event data. */
+ usbi_mutex_t event_data_lock;
+
/* 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 2248132..4313410 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10932
+#define LIBUSB_NANO 10933