summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTormod Volden <debian.tormod@gmail.com>2022-08-31 17:51:50 +0200
committerTormod Volden <debian.tormod@gmail.com>2022-09-03 11:55:10 +0200
commit432bc0954db654bd732a67c9cdc14a2e47ee5fc4 (patch)
tree2a551be386f94fe55333ee615a4c79c95e6ab730
parent2ca64b364ba8835bd4b12ce6ec86f5aec72bb9e4 (diff)
downloadlibusb-432bc0954db654bd732a67c9cdc14a2e47ee5fc4.tar.gz
core: Avoid mutex lock while printing error and warning
Closes #1187 Reviewed-by: Dmitry Zakablukov <dimaz@passware.com> Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
-rw-r--r--libusb/core.c8
-rw-r--r--libusb/version_nano.h2
2 files changed, 6 insertions, 4 deletions
diff --git a/libusb/core.c b/libusb/core.c
index 5951816..d4f4d9f 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -1398,20 +1398,22 @@ static void do_close(struct libusb_context *ctx,
for_each_transfer_safe(ctx, itransfer, tmp) {
struct libusb_transfer *transfer =
USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
+ uint32_t state_flags;
if (transfer->dev_handle != dev_handle)
continue;
usbi_mutex_lock(&itransfer->lock);
- if (!(itransfer->state_flags & USBI_TRANSFER_DEVICE_DISAPPEARED)) {
+ state_flags = itransfer->state_flags;
+ usbi_mutex_unlock(&itransfer->lock);
+ if (!(state_flags & USBI_TRANSFER_DEVICE_DISAPPEARED)) {
usbi_err(ctx, "Device handle closed while transfer was still being processed, but the device is still connected as far as we know");
- if (itransfer->state_flags & USBI_TRANSFER_CANCELLING)
+ if (state_flags & USBI_TRANSFER_CANCELLING)
usbi_warn(ctx, "A cancellation for an in-flight transfer hasn't completed but closing the device handle");
else
usbi_err(ctx, "A cancellation hasn't even been scheduled on the transfer for which the device is closing");
}
- usbi_mutex_unlock(&itransfer->lock);
/* remove from the list of in-flight transfers and make sure
* we don't accidentally use the device handle in the future
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 173c4f9..dd859e7 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11743
+#define LIBUSB_NANO 11744