VirtualBox

Changeset 38729 in vbox


Ignore:
Timestamp:
Sep 13, 2011 9:50:58 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
73997
Message:

Main/Medium+Machine: fix lock order issues when creating diff images, and eliminate a bit of redundant code.

Location:
trunk/src/VBox/Main/src-server
Files:
2 edited

Legend:

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

    r38717 r38729  
    34193419    // request the host lock first, since might be calling Host methods for getting host drives;
    34203420    // next, protect the media tree all the while we're in here, as well as our member variables
    3421     AutoMultiWriteLock2 alock(mParent->host()->lockHandle(),
    3422                               this->lockHandle() COMMA_LOCKVAL_SRC_POS);
     3421    AutoMultiWriteLock2 alock(mParent->host(), this COMMA_LOCKVAL_SRC_POS);
    34233422    AutoWriteLock treeLock(&mParent->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
    34243423
     
    93009299    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    93019300
    9302     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     9301    AutoMultiWriteLock2 alock(this->lockHandle(),
     9302                              &mParent->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
    93039303
    93049304    /* must be in a protective state because we leave the lock below */
     
    94429442            }
    94439443
    9444             /* leave the lock before the potentially lengthy operation */
    9445             alock.leave();
     9444            /* leave the locks before the potentially lengthy operation */
     9445            alock.release();
    94469446            rc = pMedium->createDiffStorage(diff, MediumVariant_Standard,
    94479447                                            pMediumLockList,
     
    94499449                                            true /* aWait */,
    94509450                                            pllRegistriesThatNeedSaving);
    9451             alock.enter();
     9451            alock.acquire();
    94529452            if (FAILED(rc)) throw rc;
    94539453
     
    1148111481    /* Creating a Progress object requires the VirtualBox lock, and
    1148211482     * thus locking it here is required by the lock order rules. */
    11483     AutoMultiWriteLock2 alock(mParent->lockHandle(), this->lockHandle() COMMA_LOCKVAL_SRC_POS);
     11483    AutoMultiWriteLock2 alock(mParent, this COMMA_LOCKVAL_SRC_POS);
    1148411484
    1148511485    if (control == mData->mSession.mDirectControl)
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r38717 r38729  
    25292529
    25302530    // locking: we need the tree lock first because we access parent pointers
    2531     AutoReadLock treeLock(m->pVirtualBox->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
    2532     AutoMultiWriteLock2 alock(this, diff COMMA_LOCKVAL_SRC_POS);
     2531    AutoMultiWriteLock3 alock(&m->pVirtualBox->getMediaTreeLockHandle(),
     2532                              this->lockHandle(), diff->lockHandle() COMMA_LOCKVAL_SRC_POS);
    25332533
    25342534    if (m->type == MediumType_Writethrough)
     
    25732573    }
    25742574
    2575     treeLock.release();
    25762575    alock.release();
    25772576
Note: See TracChangeset for help on using the changeset viewer.

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