From 043e27a6a2b137be4639b11b785808410d1062f0 Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Sat, 24 Aug 2024 02:47:00 +0200 Subject: [PATCH] Handle usb_raw_ep_read being interrupted Commit 4a48d4662919 added a EINTR handler for usb_raw_ep_write but not for usb_raw_ep_read; fix this. Fixes #25. --- proxy.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/proxy.cpp b/proxy.cpp index 8f2a9f0..d88cdc2 100644 --- a/proxy.cpp +++ b/proxy.cpp @@ -247,6 +247,11 @@ void *ep_loop_read(void *arg) { ep.bEndpointAddress, transfer_type.c_str(), dir.c_str()); break; } + if (rv < 0 && errno == EINTR) { + printf("EP%x(%s_%s): interface likely changing, stopping thread\n", + ep.bEndpointAddress, transfer_type.c_str(), dir.c_str()); + break; + } if (rv < 0) { perror("usb_raw_ep_read()"); exit(EXIT_FAILURE);