VirtualBox

Changeset 25843 in vbox


Ignore:
Timestamp:
Jan 14, 2010 6:51:32 PM (15 years ago)
Author:
vboxsync
Message:

Main: fix deadlock candidates detected by lock validator

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MachineImpl.cpp

    r25834 r25843  
    9696
    9797Machine::Data::Data()
    98     : mSnapshotsTreeLockHandle(LOCKCLASS_OTHERLIST)
     98    : mSnapshotsTreeLockHandle(LOCKCLASS_MACHINELIST)
    9999{
    100100    mRegistered = FALSE;
     
    631631    LogFlowThisFunc(("mRegistered=%d\n", mData->mRegistered));
    632632
    633     /* Enter this object lock because there may be a SessionMachine instance
    634      * somewhere around, that shares our data and lock but doesn't use our
    635      * addCaller()/removeCaller(), and it may be also accessing the same data
    636      * members. mParent lock is necessary as well because of
    637      * SessionMachine::uninit(), etc.
    638      */
    639     AutoMultiWriteLock2 alock(mParent, this COMMA_LOCKVAL_SRC_POS);
     633    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    640634
    641635    if (!mData->mSession.mMachine.isNull())
     
    653647         * still valid). We'll call it ourselves below.
    654648         */
    655         LogWarningThisFunc(("Session machine is not NULL (%p), "
    656                              "the direct session is still open!\n",
    657                              (SessionMachine *) mData->mSession.mMachine));
    658 
    659         if (Global::IsOnlineOrTransient (mData->mMachineState))
     649        LogWarningThisFunc(("Session machine is not NULL (%p), the direct session is still open!\n",
     650                            (SessionMachine*)mData->mSession.mMachine));
     651
     652        if (Global::IsOnlineOrTransient(mData->mMachineState))
    660653        {
    661654            LogWarningThisFunc(("Setting state to Aborted!\n"));
    662655            /* set machine state using SessionMachine reimplementation */
    663             static_cast <Machine *> (mData->mSession.mMachine)
    664                 ->setMachineState (MachineState_Aborted);
     656            static_cast<Machine*>(mData->mSession.mMachine)->setMachineState (MachineState_Aborted);
    665657        }
    666658
     
    671663        mData->mSession.mMachine->uninit();
    672664        /* SessionMachine::uninit() must set mSession.mMachine to null */
    673         Assert (mData->mSession.mMachine.isNull());
     665        Assert(mData->mSession.mMachine.isNull());
    674666    }
    675667
     
    97419733 *  filter for the given USB device and @c false otherwise.
    97429734 *
    9743  *  @note Locks this object for reading.
     9735 *  @note Caller must have requested machine read lock.
    97449736 */
    97459737bool SessionMachine::hasMatchingUSBFilter (const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs)
     
    97519743        return false;
    97529744
    9753     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     9745    AssertReturn(isWriteLockOnCurrentThread(), false);
    97549746
    97559747#ifdef VBOX_WITH_USB
  • trunk/src/VBox/Main/MediumImpl.cpp

    r25836 r25843  
    12561256 *       uninit() methods.
    12571257 *
    1258  * @note Locks getTreeLock() for writing, VirtualBox for writing.
     1258 * @note Caller must hold the tree lock of the medium tree this medium is on.
    12591259 */
    12601260void Medium::uninit()
     
    12811281    else
    12821282    {
    1283         /* we uninit children and reset mParent
    1284          * and VirtualBox::removeDependentChild() needs a write lock */
    1285         AutoWriteLock alock1(m->pVirtualBox->lockHandle() COMMA_LOCKVAL_SRC_POS);
    1286         AutoWriteLock alock2(m->pVirtualBox->hardDiskTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
    1287 
    12881283        MediaList::iterator it;
    12891284        for (it = m->llChildren.begin();
     
    30553050    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    30563051
    3057     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    3058 
    30593052    /* we access mParent */
    30603053    AutoReadLock treeLock(m->pVirtualBox->hardDiskTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
     3054
     3055    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    30613056
    30623057    data.uuid = m->id;
  • trunk/src/VBox/Main/NetworkAdapterImpl.cpp

    r25346 r25843  
    906906    AutoCaller autoCaller(this);
    907907    AssertComRCReturnRC(autoCaller.rc());
    908 
    909     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    910908
    911909    /* Note: we assume that the default values for attributes of optional
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