* 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
This commit is contained in:
Jérôme Duval
2008-09-03 19:18:42 +00:00
parent 1ccc2f2d7b
commit 56ff2527e9
2 changed files with 3 additions and 2 deletions
@@ -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;
@@ -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;