Merge pull request #301 from riscv/mpsse_flush

Add wall clock timeout to mpsse_flush()
This commit is contained in:
Megan Wachs
2018-09-18 09:36:19 -07:00
committed by GitHub
+7
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: