Windows: Update transferred data on timeout or cancel.
authorToby Gray <toby.gray@realvnc.com>
Wed, 13 Feb 2013 15:21:52 +0000 (15:21 +0000)
committerPete Batard <pete@akeo.ie>
Thu, 14 Feb 2013 00:11:10 +0000 (00:11 +0000)
* 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
libusb/version_nano.h

index 8a8caf4..fff21f3 100644 (file)
@@ -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;
index cd49855..c6aa34d 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10603
+#define LIBUSB_NANO 10604