libusb: when USB device vanishs throw exception

* Instead of repeatedly spam the log with errors and
  bring heavy load to the USB host controller driver
  abort yourself when the device vanishs

Fix genodelabs/genode#4515
This commit is contained in:
Stefan Kalkowski 2022-05-20 15:33:02 +02:00 committed by Christian Helmuth
parent 03349f9fff
commit ba6a3526a9

View File

@ -59,6 +59,8 @@ struct Usb_device
public:
struct Device_has_vanished {};
Usb::Connection *usb_connection;
Usb::Device_descriptor device_descriptor;
@ -161,8 +163,11 @@ struct Usb_device
}
if (!p.succeded || itransfer->flags & USBI_TRANSFER_CANCELLING) {
if (!p.succeded)
if (!p.succeded) {
Genode::error("USB transfer failed: ", (unsigned)p.type);
if (p.error == Usb::Packet_descriptor::NO_DEVICE_ERROR)
throw Device_has_vanished();
}
itransfer->transferred = 0;
usb_connection->source()->release_packet(p);
usbi_signal_transfer_completion(itransfer);