From 5541bafa48b6075488313d8b57c2c7c9a2359ba4 Mon Sep 17 00:00:00 2001 From: Toby Gray Date: Wed, 13 Feb 2013 15:21:52 +0000 Subject: [PATCH] Windows: Update transferred data on timeout or cancel. * When handling aborted transfer it's possible that some data (but not the full buffer) was transferred. * This change ensures that this partially transferred data is recorded and passed up to the caller. --- libusb/os/windows_usb.c | 8 ++++++-- libusb/version_nano.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index 8a8caf4..fff21f3 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -2030,9 +2030,9 @@ static void windows_transfer_callback(struct usbi_transfer *itransfer, uint32_t { struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer); struct windows_device_priv *priv = _device_priv(transfer->dev_handle->dev); - int status; + int status, istatus; - usbi_dbg("handling I/O completion with errcode %d", io_result); + usbi_dbg("handling I/O completion with errcode %d, size %d", io_result, io_size); switch(io_result) { case NO_ERROR: @@ -2047,6 +2047,10 @@ static void windows_transfer_callback(struct usbi_transfer *itransfer, uint32_t status = LIBUSB_TRANSFER_TIMED_OUT; break; case ERROR_OPERATION_ABORTED: + istatus = priv->apib->copy_transfer_data(SUB_API_NOTSET, itransfer, io_size); + if (istatus != LIBUSB_TRANSFER_COMPLETED) { + usbi_dbg("Failed to copy partial data in aborted operation: %d", istatus); + } if (itransfer->flags & USBI_TRANSFER_TIMED_OUT) { usbi_dbg("detected timeout"); status = LIBUSB_TRANSFER_TIMED_OUT; diff --git a/libusb/version_nano.h b/libusb/version_nano.h index cd49855..c6aa34d 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10603 +#define LIBUSB_NANO 10604 -- 2.7.4