From ba6a3526a92d9c940a4c3df55e29175446691700 Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Fri, 20 May 2022 15:33:02 +0200 Subject: [PATCH] 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 --- repos/libports/src/lib/libusb/genode_usb_raw.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/repos/libports/src/lib/libusb/genode_usb_raw.cc b/repos/libports/src/lib/libusb/genode_usb_raw.cc index e2e960bc32..a861e82e7b 100644 --- a/repos/libports/src/lib/libusb/genode_usb_raw.cc +++ b/repos/libports/src/lib/libusb/genode_usb_raw.cc @@ -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);