core: Add new lock to protect internal context event data
authorChris Dickens <christopher.a.dickens@gmail.com>
Tue, 18 Nov 2014 07:53:08 +0000 (23:53 -0800)
committerChris Dickens <chris.dickens@hp.com>
Fri, 19 Dec 2014 19:12:48 +0000 (11:12 -0800)
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>
libusb/io.c
libusb/libusbi.h
libusb/version_nano.h

index 7700e8c..2b3c755 100644 (file)
@@ -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)
index ffca4a3..b1c056e 100644 (file)
@@ -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;
index 2248132..4313410 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10932
+#define LIBUSB_NANO 10933