VirtualBox

Changeset 27774 in vbox


Ignore:
Timestamp:
Mar 29, 2010 10:44:37 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
59420
Message:

Main: fix locking order violation in Medium::CloneTo()

File:
1 edited

Legend:

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

    r27663 r27774  
    24312431        parent = static_cast<Medium*>(aParent);
    24322432
    2433     AutoMultiWriteLock3 alock(this, target, parent COMMA_LOCKVAL_SRC_POS);
    2434 
    24352433    ComObjPtr<Progress> progress;
    24362434    HRESULT rc = S_OK;
     
    24382436    try
    24392437    {
     2438        // locking: we need the tree lock first because we access parent pointers
     2439        AutoReadLock treeLock(m->pVirtualBox->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
     2440        // and we need to write-lock the images involved
     2441        AutoMultiWriteLock3 alock(this, target, parent COMMA_LOCKVAL_SRC_POS);
     2442
    24402443        if (    target->m->state != MediumState_NotCreated
    24412444            &&  target->m->state != MediumState_Created)
     
    24492452        std::auto_ptr <ImageChain> srcChain(new ImageChain());
    24502453
    2451         /* we walk the source tree */
    2452         AutoReadLock treeLock(m->pVirtualBox->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
    24532454        for (Medium *hd = this;
    24542455             hd;
     
    25212522
    25222523    if (SUCCEEDED(rc))
    2523     {
    25242524        /* return progress to the caller */
    25252525        progress.queryInterfaceTo(aProgress);
    2526     }
    25272526
    25282527    return rc;
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