From c775c2f43037cd235b65410583179195e25f9c4a Mon Sep 17 00:00:00 2001 From: Vitali Lovich Date: Wed, 16 Mar 2011 19:51:40 -0700 Subject: 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] --- libusb/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libusb/io.c') 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); -- cgit v1.2.1