VirtualBox

Ignore:
Timestamp:
Mar 29, 2010 4:04:55 PM (15 years ago)
Author:
vboxsync
Message:

Main: attempt at USB locking fixes

File:
1 edited

Legend:

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

    r27793 r27796  
    47204720    CheckComArgExpr(aData, !ComSafeArrayOutIsNull(aData));
    47214721
     4722    NOREF(aDataSize);
     4723
    47224724    ReturnComNotImplemented();
    47234725}
     
    91399141    }
    91409142
    9141     /* We need to lock this object in uninit() because the lock is shared
    9142      * with mPeer (as well as data we modify below). mParent->addProcessToReap()
    9143      * and others need mParent lock, and USB needs host lock. */
    9144     AutoMultiWriteLock3 alock(mParent, mParent->host(), this COMMA_LOCKVAL_SRC_POS);
    9145 
    9146 #ifdef VBOX_WITH_RESOURCE_USAGE_API
    9147     unregisterMetrics(mParent->performanceCollector(), mPeer);
    9148 #endif /* VBOX_WITH_RESOURCE_USAGE_API */
    9149 
    9150     MachineState_T lastState = mData->mMachineState;
     9143    MachineState_T lastState;
     9144    {
     9145        AutoReadLock tempLock(this COMMA_LOCKVAL_SRC_POS);
     9146        lastState = mData->mMachineState;
     9147    }
    91519148    NOREF(lastState);
    91529149
    9153     if (aReason == Uninit::Abnormal)
    9154     {
    9155         LogWarningThisFunc(("ABNORMAL client termination! (wasBusy=%d)\n",
    9156                              Global::IsOnlineOrTransient(lastState)));
    9157 
    9158         /* reset the state to Aborted */
    9159         if (mData->mMachineState != MachineState_Aborted)
    9160             setMachineState(MachineState_Aborted);
    9161     }
    9162 
    9163     // any machine settings modified?
    9164     if (m_flModifications)
    9165     {
    9166         LogWarningThisFunc(("Discarding unsaved settings changes!\n"));
    9167         rollback(false /* aNotify */);
    9168     }
    9169 
    9170     Assert(mSnapshotData.mStateFilePath.isEmpty() || !mSnapshotData.mSnapshot);
    9171     if (!mSnapshotData.mStateFilePath.isEmpty())
    9172     {
    9173         LogWarningThisFunc(("canceling failed save state request!\n"));
    9174         endSavingState(FALSE /* aSuccess  */);
    9175     }
    9176     else if (!mSnapshotData.mSnapshot.isNull())
    9177     {
    9178         LogWarningThisFunc(("canceling untaken snapshot!\n"));
    9179 
    9180         /* delete all differencing hard disks created (this will also attach
    9181          * their parents back by rolling back mMediaData) */
    9182         rollbackMedia();
    9183         /* delete the saved state file (it might have been already created) */
    9184         if (mSnapshotData.mSnapshot->stateFilePath().length())
    9185             RTFileDelete(mSnapshotData.mSnapshot->stateFilePath().c_str());
    9186 
    9187         mSnapshotData.mSnapshot->uninit();
    9188     }
    9189 
    91909150#ifdef VBOX_WITH_USB
    9191     /* release all captured USB devices */
     9151    // release all captured USB devices, but do this before requesting the locks below
    91929152    if (aReason == Uninit::Abnormal && Global::IsOnline(lastState))
    91939153    {
     
    92099169    }
    92109170#endif /* VBOX_WITH_USB */
     9171
     9172    // we need to lock this object in uninit() because the lock is shared
     9173    // with mPeer (as well as data we modify below). mParent->addProcessToReap()
     9174    // and others need mParent lock, and USB needs host lock.
     9175    AutoMultiWriteLock3 multilock(mParent, mParent->host(), this COMMA_LOCKVAL_SRC_POS);
     9176
     9177#ifdef VBOX_WITH_RESOURCE_USAGE_API
     9178    unregisterMetrics(mParent->performanceCollector(), mPeer);
     9179#endif /* VBOX_WITH_RESOURCE_USAGE_API */
     9180
     9181    if (aReason == Uninit::Abnormal)
     9182    {
     9183        LogWarningThisFunc(("ABNORMAL client termination! (wasBusy=%d)\n",
     9184                             Global::IsOnlineOrTransient(lastState)));
     9185
     9186        /* reset the state to Aborted */
     9187        if (mData->mMachineState != MachineState_Aborted)
     9188            setMachineState(MachineState_Aborted);
     9189    }
     9190
     9191    // any machine settings modified?
     9192    if (m_flModifications)
     9193    {
     9194        LogWarningThisFunc(("Discarding unsaved settings changes!\n"));
     9195        rollback(false /* aNotify */);
     9196    }
     9197
     9198    Assert(mSnapshotData.mStateFilePath.isEmpty() || !mSnapshotData.mSnapshot);
     9199    if (!mSnapshotData.mStateFilePath.isEmpty())
     9200    {
     9201        LogWarningThisFunc(("canceling failed save state request!\n"));
     9202        endSavingState(FALSE /* aSuccess  */);
     9203    }
     9204    else if (!mSnapshotData.mSnapshot.isNull())
     9205    {
     9206        LogWarningThisFunc(("canceling untaken snapshot!\n"));
     9207
     9208        /* delete all differencing hard disks created (this will also attach
     9209         * their parents back by rolling back mMediaData) */
     9210        rollbackMedia();
     9211        /* delete the saved state file (it might have been already created) */
     9212        if (mSnapshotData.mSnapshot->stateFilePath().length())
     9213            RTFileDelete(mSnapshotData.mSnapshot->stateFilePath().c_str());
     9214
     9215        mSnapshotData.mSnapshot->uninit();
     9216    }
    92119217
    92129218    if (!mData->mSession.mType.isEmpty())
     
    93269332
    93279333    /* leave the exclusive lock before setting the below two to NULL */
    9328     alock.leave();
     9334    multilock.leave();
    93299335
    93309336    unconst(mParent) = NULL;
     
    1081810824        /* Make sure any transient guest properties get removed from the
    1081910825         * property store on shutdown. */
    10820        
     10826
    1082110827        HWData::GuestPropertyList::iterator it;
    1082210828        BOOL fNeedsSaving = mHWData->mGuestPropertiesModified;
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