From: Chris Dickens Date: Tue, 18 Nov 2014 07:53:08 +0000 (-0800) Subject: core: Add new lock to protect internal context event data X-Git-Tag: upstream/1.0.21~223 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0e62e5cf34cd02e811157ecb4c6725f2b940a136;p=platform%2Fupstream%2Flibusb.git 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 --- 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