Add wall clock timeout to mpsse_flush()
I think that libusb_handle_events_timeout_completed is supposed to make progress or time out, but sometimes we hit a case where it makes no progress, and mpsse_flush() loops forever. This wall clock timeout kicks it out of that loop. OpenOCD appears to die afterwards, but that's still an improvement. Change-Id: Id9220557625834fb5b7dccf65251651a11a887f0
This commit is contained in:
parent
933cb875a8
commit
af501f4905
|
@ -892,6 +892,7 @@ int mpsse_flush(struct mpsse_ctx *ctx)
|
|||
}
|
||||
|
||||
/* Polling loop, more or less taken from libftdi */
|
||||
int64_t start = timeval_ms();
|
||||
while (!write_result.done || !read_result.done) {
|
||||
struct timeval timeout_usb;
|
||||
|
||||
|
@ -914,6 +915,11 @@ int mpsse_flush(struct mpsse_ctx *ctx)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (timeval_ms() - start > 2000) {
|
||||
LOG_ERROR("Timed out handling USB events in mpsse_flush().");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
error_check:
|
||||
|
|
Loading…
Reference in New Issue