VirtualBox

Changeset 31327 in vbox


Ignore:
Timestamp:
Aug 3, 2010 10:34:16 AM (14 years ago)
Author:
vboxsync
Message:

Main: fix locking order violations introduced by r64323 by using a new, separate lock for the host drives

File:
1 edited

Legend:

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

    r31296 r31327  
    159159          usbListsLock(LOCKCLASS_USBLIST),
    160160#endif
     161          drivesLock(LOCKCLASS_LISTOFMEDIA),
    161162          fDVDDrivesListBuilt(false),
    162163          fFloppyDrivesListBuilt(false)
     
    176177
    177178    // list of host drives; lazily created by getDVDDrives() and getFloppyDrives()
     179    WriteLockHandle         drivesLock;                 // protects the below two lists and the bools
    178180    MediaList               llDVDDrives,
    179181                            llFloppyDrives;
     
    416418    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    417419
    418     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     420    AutoWriteLock alock(m->drivesLock COMMA_LOCKVAL_SRC_POS);
    419421
    420422    MediaList *pList;
     
    442444    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    443445
    444     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     446    AutoWriteLock alock(m->drivesLock COMMA_LOCKVAL_SRC_POS);
    445447
    446448    MediaList *pList;
     
    15271529 * that may have changed if fRefresh == true.
    15281530 *
    1529  * The caller must hold the Host write lock before calling this.
     1531 * The caller must hold the m->drivesLock write lock before calling this.
    15301532 * To protect the list to which the caller's pointer points, the caller
    1531  * must also hold the Host lock.
     1533 * must also hold that lock.
    15321534 *
    15331535 * @param mediumType Must be DeviceType_Floppy or DeviceType_DVD.
     
    15411543{
    15421544    HRESULT rc = S_OK;
    1543     Assert(isWriteLockOnCurrentThread());
     1545    Assert(m->drivesLock.isWriteLockOnCurrentThread());
    15441546
    15451547    MediaList llNew;
     
    16501652 * and looks for a host drive with the given UUID. If found, it sets pMedium
    16511653 * to that drive; otherwise returns VBOX_E_OBJECT_NOT_FOUND.
     1654 *
    16521655 * @param mediumType Must be DeviceType_DVD or DeviceType_Floppy.
    16531656 * @param uuid Medium UUID of host drive to look for.
     
    16631666    MediaList *pllMedia;
    16641667
    1665     AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS);
     1668    AutoWriteLock wlock(m->drivesLock COMMA_LOCKVAL_SRC_POS);
    16661669    HRESULT rc = getDrives(mediumType, fRefresh, pllMedia);
    16671670    if (SUCCEEDED(rc))
     
    16921695    HRESULT rc = S_OK;
    16931696
    1694     Assert(isWriteLockOnCurrentThread());
     1697    Assert(m->drivesLock.isWriteLockOnCurrentThread());
    16951698
    16961699    try
     
    18091812    HRESULT rc = S_OK;
    18101813
    1811     Assert(isWriteLockOnCurrentThread());
     1814    Assert(m->drivesLock.isWriteLockOnCurrentThread());
    18121815
    18131816    try
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