From 56ff2527e924161061cf884640d7b21794dd5184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Wed, 3 Sep 2008 19:18:42 +0000 Subject: [PATCH] * on freeing, only remove the device when it is removed * check if the device is still opened when waiting for data git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27310 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp | 3 ++- src/add-ons/kernel/drivers/input/usb_hid/MouseDevice.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp b/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp index df351fd51d..ca42fd0d9c 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp +++ b/src/add-ons/kernel/drivers/input/usb_hid/Driver.cpp @@ -191,7 +191,8 @@ usb_hid_free(void *cookie) HIDDevice *device = (HIDDevice *)cookie; mutex_lock(&sDriverLock); status_t status = device->Free(); - if (gDeviceList->RemoveDevice(NULL, device) == B_OK) { + if (device->IsRemoved() + && gDeviceList->RemoveDevice(NULL, device) == B_OK) { // the device is removed already but as it was open the removed hook // has not deleted the object delete device; diff --git a/src/add-ons/kernel/drivers/input/usb_hid/MouseDevice.cpp b/src/add-ons/kernel/drivers/input/usb_hid/MouseDevice.cpp index 412b03ef1f..e42e5e4f75 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/MouseDevice.cpp +++ b/src/add-ons/kernel/drivers/input/usb_hid/MouseDevice.cpp @@ -46,7 +46,7 @@ MouseDevice::Control(uint32 op, void *buffer, size_t length) // released in the callback function status_t result = acquire_sem_etc(fTransferNotifySem, 1, B_CAN_INTERRUPT, 0); - if (result == B_INTERRUPTED) + if (result == B_INTERRUPTED && IsOpen()) continue; else if (result != B_OK) return result;