VirtualBox

Changeset 29940 in vbox for trunk/src


Ignore:
Timestamp:
Jun 1, 2010 11:09:44 AM (15 years ago)
Author:
vboxsync
Message:

Main/Medium: fix a couple of lock order violations around calling VirtualBox::saveSettings, plus eliminating some leave() method calls where release() is obviously the same thing

File:
1 edited

Legend:

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

    r29618 r29940  
    14411441    m->type = aType;
    14421442
     1443    mlock.release();
     1444
    14431445    // saveSettings needs vbox lock
    1444     ComObjPtr<VirtualBox> pVirtualBox(m->pVirtualBox);
    1445     mlock.leave();
    14461446    AutoWriteLock alock(m->pVirtualBox COMMA_LOCKVAL_SRC_POS);
    14471447
    1448     HRESULT rc = pVirtualBox->saveSettings();
     1448    HRESULT rc = m->pVirtualBox->saveSettings();
    14491449
    14501450    return rc;
     
    15591559    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    15601560
    1561     /* VirtualBox::saveSettings() needs a write lock */
    1562     AutoMultiWriteLock2 alock(m->pVirtualBox, this COMMA_LOCKVAL_SRC_POS);
     1561    AutoWriteLock mlock(this COMMA_LOCKVAL_SRC_POS);
    15631562
    15641563    if (m->pParent.isNull())
     
    15701569    {
    15711570        m->autoReset = !!aAutoReset;
     1571
     1572        mlock.release();
     1573
     1574        // saveSettings needs vbox lock
     1575        AutoWriteLock alock(m->pVirtualBox COMMA_LOCKVAL_SRC_POS);
    15721576
    15731577        return m->pVirtualBox->saveSettings();
     
    19801984    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    19811985
    1982     /* VirtualBox::saveSettings() needs a write lock */
    1983     AutoMultiWriteLock2 alock(m->pVirtualBox, this COMMA_LOCKVAL_SRC_POS);
     1986    AutoWriteLock mlock(this COMMA_LOCKVAL_SRC_POS);
    19841987
    19851988    switch (m->state)
     
    20032006        it->second = aValue;
    20042007
     2008    mlock.release();
     2009
     2010    // saveSettings needs vbox lock
     2011    AutoWriteLock alock(m->pVirtualBox COMMA_LOCKVAL_SRC_POS);
    20052012    HRESULT rc = m->pVirtualBox->saveSettings();
    20062013
     
    20512058    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    20522059
    2053     /* VirtualBox::saveSettings() needs a write lock */
    2054     AutoMultiWriteLock2 alock(m->pVirtualBox, this COMMA_LOCKVAL_SRC_POS);
     2060    AutoWriteLock mlock(this COMMA_LOCKVAL_SRC_POS);
    20552061
    20562062    com::SafeArray<IN_BSTR> names(ComSafeArrayInArg(aNames));
     
    20812087    }
    20822088
     2089    mlock.release();
     2090
     2091    // saveSettings needs vbox lock
     2092    AutoWriteLock alock(m->pVirtualBox COMMA_LOCKVAL_SRC_POS);
    20832093    HRESULT rc = m->pVirtualBox->saveSettings();
    20842094
     
    34493459
    34503460        alock.leave();
    3451 
    34523461        vrc = RTSemEventMultiWait(m->queryInfoSem, RT_INDEFINITE_WAIT);
    3453 
    34543462        alock.enter();
    34553463
     
    51615169
    51625170        /* unlock before the potentially lengthy operation */
    5163         thisLock.leave();
     5171        thisLock.release();
    51645172
    51655173        try
     
    52955303        /* the two media are now protected by their non-default states;
    52965304         * unlock the media before the potentially lengthy operation */
    5297         mediaLock.leave();
     5305        mediaLock.release();
    52985306
    52995307        try
     
    54125420        if (fNeedsSaveSettings)
    54135421        {
    5414             mediaLock.leave();
     5422            mediaLock.release();
    54155423            AutoWriteLock vboxlock(m->pVirtualBox COMMA_LOCKVAL_SRC_POS);
    54165424            m->pVirtualBox->saveSettings();
     
    58175825
    58185826            /* unlock before the potentially lengthy operation */
    5819             thisLock.leave();
     5827            thisLock.release();
    58205828
    58215829            /* ensure the target directory exists */
     
    62386246
    62396247            /* unlock before the potentially lengthy operation */
    6240             thisLock.leave();
     6248            thisLock.release();
    62416249
    62426250            vrc = VDCompact(hdd, VD_LAST_IMAGE, task.mVDOperationIfaces);
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