Merge pull request #301 from riscv/mpsse_flush

Add wall clock timeout to mpsse_flush()
old_fixes_and_eclipse_memory_read
Megan Wachs 2018-09-18 09:36:19 -07:00 committed by GitHub
commit 35eed36ffd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -22,6 +22,7 @@
#include "mpsse.h"
#include "helper/log.h"
#include "helper/time_support.h"
#include <libusb.h>
/* Compatibility define for older libusb-1.0 */
@ -892,6 +893,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 +916,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: