Fix support for proxying devices that switch interface altsettings
xairy opened this issue · comments
Even though #6 added basic support for devices that switch between interface altsettings, it might not work properly in certain cases: the endpoint handling threads might fail to be joined, as they might be blocked on libusb or Raw Gadget transfers.
Interrupting Raw Gadget transfers is simple: just send any signal to the endpoint threads via pthread_kill
and add a no-op handler for this signal (but perhaps a signal other than SIGINT
, as USB Proxy already uses this signal internally).
However, interrupting the libusb transfers is a problem.
A simple solution would be use the timeout
argument of the libusb sync I/O API, but unfortunately libusb has a bug that makes sync I/O ignore the timeout
argument.
We need to either switch to using async libusb I/O or figure out another way to interrupt libusb transfers (without fully resetting the device, as done in #14).
Ah, actually libusb timeouts work as expected, it's just that receive_data
zeroes out timeout
.