Read fxlink messages in a loop to properly flush the new IN queue
This is required since Lephenixnoir/fxsdk@85d7fcf9e9 as new messages are now added to a queue to fix a race condition that occurred because it's possible to read more than one in a single libusb_handle_events(). See Lephenixnoir/gint#27
This commit is contained in:
parent
8c41aba127
commit
c01efc7804
14
src/main.c
14
src/main.c
|
@ -115,8 +115,8 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
struct timeval zero = {0};
|
||||
libusb_handle_events_timeout(context, &zero);
|
||||
struct fxlink_message* msg = fxlink_device_finish_bulk_IN(dev);
|
||||
if (msg) {
|
||||
struct fxlink_message* msg;
|
||||
while ((msg = fxlink_device_finish_bulk_IN(dev)) != NULL) {
|
||||
if (!fxlink_message_is_apptype(msg, "gdb", "remote")) {
|
||||
elog("unknown fxlink message type\n");
|
||||
ret = -1;
|
||||
|
@ -130,15 +130,13 @@ int main(int argc, char* argv[]) {
|
|||
}
|
||||
fxlink_message_free(msg, true);
|
||||
|
||||
// TODO : Uhu ?
|
||||
/* if (!fxlink_device_start_bulk_IN(dev)) {
|
||||
* elog("unable to start bulk IN trasfer\n");
|
||||
* return -1;
|
||||
* }
|
||||
*/
|
||||
fxlink_device_start_bulk_IN(dev);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
// We don't want to start a new OUT transfer if another one is still in progress
|
||||
if (!dev->comm->ftransfer_OUT) {
|
||||
int bytes_socket;
|
||||
|
|
Loading…
Reference in New Issue