summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTormod Volden <debian.tormod@gmail.com>2021-10-28 14:48:55 +0200
committerTormod Volden <debian.tormod@gmail.com>2021-11-09 09:19:59 +0100
commit5b408d108407043a8736dd36f2c1e1ee9f52394e (patch)
tree9556df86aa0136b2394ac99f2c243912e63094b2
parent7b342030d293019696ff536a95105c654167461a (diff)
downloadlibusb-5b408d108407043a8736dd36f2c1e1ee9f52394e.tar.gz
libusb-5b408d108407043a8736dd36f2c1e1ee9f52394e.tar.bz2
libusb-5b408d108407043a8736dd36f2c1e1ee9f52394e.zip
Windows: Allow synchronous control transfers (for libusb0)
Some of the changes in commit 9c28ad2 rely on all transfers having (or appearing to have) asynchronous completion. However, the libusb0.sys backend of libusbk.dll performs all control transfers synchronously and ignores any "overlapped" structure handed to it. Our asynchronous handling will in this case be pending and eventually time out although the USB request itself was successful. Therefore restore the possibility of synchronous completion of control transfers, by forcing the completion handling on a successful return from request submission. This brings the code closer to how it was established in commit ce95f65. Fixes #94 Tested-by: Xiaofan Chen <xiaofanc@gmail.com> Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
-rw-r--r--libusb/os/windows_winusb.c6
-rw-r--r--libusb/version_nano.h2
2 files changed, 5 insertions, 3 deletions
diff --git a/libusb/os/windows_winusb.c b/libusb/os/windows_winusb.c
index df17d81..a03d6a5 100644
--- a/libusb/os/windows_winusb.c
+++ b/libusb/os/windows_winusb.c
@@ -2766,7 +2766,7 @@ static int winusbx_submit_control_transfer(int sub_api, struct usbi_transfer *it
struct winusb_transfer_priv *transfer_priv = get_winusb_transfer_priv(itransfer);
struct winusb_device_handle_priv *handle_priv = get_winusb_device_handle_priv(transfer->dev_handle);
PWINUSB_SETUP_PACKET setup = (PWINUSB_SETUP_PACKET)transfer->buffer;
- ULONG size;
+ ULONG size, transferred;
HANDLE winusb_handle;
OVERLAPPED *overlapped;
int current_interface;
@@ -2806,11 +2806,13 @@ static int winusbx_submit_control_transfer(int sub_api, struct usbi_transfer *it
}
windows_force_sync_completion(itransfer, 0);
} else {
- if (!WinUSBX[sub_api].ControlTransfer(winusb_handle, *setup, transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE, size, NULL, overlapped)) {
+ if (!WinUSBX[sub_api].ControlTransfer(winusb_handle, *setup, transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE, size, &transferred, overlapped)) {
if (GetLastError() != ERROR_IO_PENDING) {
usbi_warn(TRANSFER_CTX(transfer), "ControlTransfer failed: %s", windows_error_str(0));
return LIBUSB_ERROR_IO;
}
+ } else {
+ windows_force_sync_completion(itransfer, transferred);
}
}
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 838c0a6..09d6e2e 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11673
+#define LIBUSB_NANO 11674