io: Clear transfer timeout struct when transfer has no timeout

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>
This commit is contained in:
Chris Dickens 2017-08-18 17:30:38 -07:00
parent 1fe3db7919
commit 2cefbc80f2

View 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) {