summaryrefslogtreecommitdiff
path: root/libusb/io.c
diff options
context:
space:
mode:
authorVitali Lovich <vlovich@aliph.com>2011-03-16 19:51:40 -0700
committerPeter Stuge <peter@stuge.se>2011-07-24 22:29:09 +0200
commitc775c2f43037cd235b65410583179195e25f9c4a (patch)
tree54fb2d1a6ffb1cc21b9516738032a857fc08c7ce /libusb/io.c
parent74282582cc879f091ad1d847411337bc3fa78a2b (diff)
downloadlibusb-c775c2f43037cd235b65410583179195e25f9c4a.tar.gz
Clean up in-flight transfers and device handle when closing a device
Any in-flight transfers should properly invalidate their references to device handles that are being closed. Additionally, they should be removed from the transfer-in-flight list. This is done with the events lock held to protect against another thread processing the same transfer. The events lock is initialized as a recursive mutex, because the device close code might itself be called while an event is being handled. Fixes #82. [stuge: Trivial rework to reduce indenting]
Diffstat (limited to 'libusb/io.c')
-rw-r--r--libusb/io.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libusb/io.c b/libusb/io.c
index 3ef422a..d0112a1 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -1012,7 +1012,7 @@ int usbi_io_init(struct libusb_context *ctx)
usbi_mutex_init(&ctx->flying_transfers_lock, NULL);
usbi_mutex_init(&ctx->pollfds_lock, NULL);
usbi_mutex_init(&ctx->pollfd_modify_lock, NULL);
- usbi_mutex_init(&ctx->events_lock, NULL);
+ usbi_mutex_init_recursive(&ctx->events_lock, NULL);
usbi_mutex_init(&ctx->event_waiters_lock, NULL);
usbi_cond_init(&ctx->event_waiters_cond, NULL);
list_init(&ctx->flying_transfers);