io: Clear transfer timeout struct when transfer has no timeout
authorChris Dickens <christopher.a.dickens@gmail.com>
Sat, 19 Aug 2017 00:30:38 +0000 (17:30 -0700)
committerChris Dickens <christopher.a.dickens@gmail.com>
Sat, 19 Aug 2017 01:21:19 +0000 (18:21 -0700)
Prior to this commit, a transfer that was submitted with a non-zero
timeout would retain this timeout if the transfer was resubmitted with
a zero (unlimited) timeout. This commit corrects this by clearing the
transfer's timeout if the desired timeout is zero.

Closes #332

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/io.c

index fc5dc2e..07e0ab8 100644 (file)
@@ -1205,8 +1205,10 @@ static int calculate_timeout(struct usbi_transfer *transfer)
        unsigned int timeout =
                USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer)->timeout;
 
-       if (!timeout)
+       if (!timeout) {
+               timerclear(&transfer->timeout);
                return 0;
+       }
 
        r = usbi_backend.clock_gettime(USBI_CLOCK_MONOTONIC, &current_time);
        if (r < 0) {