VirtualBox

Ignore:
Timestamp:
May 31, 2012 4:48:33 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
78291
Message:

Main/HostUSBDevice(all platforms)+USBProxyService: redo USB locking, fixes major regression, added lots of assertions to catch locking flaws early, whitespace cleanup
Main/Machine: small USB locking fix to be consistent with the remaining code
Main/Host+glue/AutoLock: replace USB list lock by host lock, small numbering cleanup
Main/Console: redo USB locking, do less in USB callbacks/EMT (addresses long standing todo items), eliminate unsafe iterator parameters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/freebsd/USBProxyServiceFreeBSD.cpp

    r37599 r41528  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2005-2012 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    111111int USBProxyServiceFreeBSD::captureDevice(HostUSBDevice *aDevice)
    112112{
    113     Log(("USBProxyServiceFreeBSD::captureDevice: %p {%s}\n", aDevice, aDevice->getName().c_str()));
    114113    AssertReturn(aDevice, VERR_GENERAL_FAILURE);
    115     AssertReturn(aDevice->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE);
     114    AssertReturn(!aDevice->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE);
     115
     116    AutoReadLock devLock(aDevice COMMA_LOCKVAL_SRC_POS);
     117    LogFlowThisFunc(("aDevice=%s\n", aDevice->getName().c_str()));
    116118
    117119    /*
     
    119121     */
    120122    Assert(aDevice->getUnistate() == kHostUSBDeviceState_Capturing);
     123    devLock.release();
    121124    interruptWait();
    122125
     
    127130int USBProxyServiceFreeBSD::releaseDevice(HostUSBDevice *aDevice)
    128131{
    129     Log(("USBProxyServiceFreeBSD::releaseDevice: %p\n", aDevice));
    130132    AssertReturn(aDevice, VERR_GENERAL_FAILURE);
    131     AssertReturn(aDevice->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE);
     133    AssertReturn(!aDevice->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE);
     134
     135    AutoReadLock devLock(aDevice COMMA_LOCKVAL_SRC_POS);
     136    LogFlowThisFunc(("aDevice=%s\n", aDevice->getName().c_str()));
    132137
    133138    /*
     
    135140     */
    136141    Assert(aDevice->getUnistate() == kHostUSBDeviceState_ReleasingToHost);
     142    devLock.release();
    137143    interruptWait();
    138144
     
    143149bool USBProxyServiceFreeBSD::updateDeviceState(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters, SessionMachine **aIgnoreMachine)
    144150{
     151    AssertReturn(aDevice, false);
     152    AssertReturn(!aDevice->isWriteLockOnCurrentThread(), false);
     153
    145154    return updateDeviceStateFake(aDevice, aUSBDevice, aRunFilters, aIgnoreMachine);
    146155}
     
    148157
    149158/**
    150  * A device was added, we need to adjust mUdevPolls.
     159 * A device was added
    151160 *
    152161 * See USBProxyService::deviceAdded for details.
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette