From 27b95d52b8f5a4381ddbe58db05e1d4659154ea8 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 22 Jun 2008 15:07:49 +0000 Subject: [PATCH] Impose a one second timeout on all usb_disk data transfers. This should avoid hanging systems on boot, but probably just hides a problem somewhere else, as the transfers should timeout on their own if the device doesn't respond. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26082 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/drivers/disk/usb/usb_disk/usb_disk.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp b/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp index 6feee5bcef..f740d78b35 100644 --- a/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp +++ b/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp @@ -142,8 +142,18 @@ usb_disk_transfer_data(disk_device *device, bool directionIn, void *data, } do { - result = acquire_sem(device->notify); + result = acquire_sem_etc(device->notify, 1, B_RELATIVE_TIMEOUT, 1000000); + if (result == B_TIMED_OUT) { + // Cancel the transfer and collect the sem that should now be + // released through the callback on cancel. Handling of device + // reset is done in usb_disk_operation() when it detects that + // the transfer failed. + gUSBModule->cancel_queued_transfers(directionIn ? device->bulk_in + : device->bulk_out); + continue; + } } while (result == B_INTERRUPTED); + if (result != B_OK) { TRACE_ALWAYS("acquire_sem failed while waiting for data transfer\n"); return result;