Changeset 38717 in vbox for trunk/src/VBox
- Timestamp:
- Sep 12, 2011 2:48:50 PM (13 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/glue/AutoLock.cpp
r33540 r38717 5 5 6 6 /* 7 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 73 73 { LOCKCLASS_LISTOFMEDIA, "7-LISTOFMEDIA" }, 74 74 { LOCKCLASS_LISTOFOTHEROBJECTS, "8-LISTOFOTHEROBJECTS" }, 75 { LOCKCLASS_OTHEROBJECT, "9-OTHEROBJECT" }, 76 { LOCKCLASS_USBLIST, "10-USBLIST" }, 77 { LOCKCLASS_PROGRESSLIST, "11-PROGRESSLIST" }, 78 { LOCKCLASS_OBJECTSTATE, "12-OBJECTSTATE" } 75 { LOCKCLASS_MEDIUMQUERY, "9-MEDIUMQUERY" }, 76 { LOCKCLASS_OTHEROBJECT, "10-OTHEROBJECT" }, 77 { LOCKCLASS_USBLIST, "11-USBLIST" }, 78 { LOCKCLASS_PROGRESSLIST, "12-PROGRESSLIST" }, 79 { LOCKCLASS_OBJECTSTATE, "13-OBJECTSTATE" } 79 80 }; 80 81 -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r38618 r38717 12513 12513 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 12514 12514 12515 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 12515 AutoMultiWriteLock2 alock(this->lockHandle(), 12516 &mParent->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 12516 12517 12517 12518 AssertReturn( mData->mMachineState == MachineState_Starting -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r38709 r38717 88 88 readers(0), 89 89 preLockState(MediumState_NotCreated), 90 queryInfoSem( NIL_RTSEMRW),90 queryInfoSem(LOCKCLASS_MEDIUMQUERY), 91 91 queryInfoRunning(false), 92 92 type(MediumType_Normal), … … 129 129 * which we had here for many years. Catching possible deadlocks is more 130 130 * important than a tiny bit of efficiency. */ 131 R TSEMRWqueryInfoSem;131 RWLockHandle queryInfoSem; 132 132 bool queryInfoRunning : 1; 133 133 … … 891 891 AssertRCReturn(vrc, E_FAIL); 892 892 893 vrc = RTSemRWCreate(&m->queryInfoSem);894 AssertRCReturn(vrc, E_FAIL);895 896 893 return BaseFinalConstruct(); 897 894 } … … 1372 1369 } 1373 1370 1374 RTSemRWDestroy(m->queryInfoSem);1375 m->queryInfoSem = NIL_RTSEMRW;1376 1377 1371 unconst(m->pVirtualBox) = NULL; 1378 1372 } … … 2008 2002 2009 2003 /* queryInfo() locks this for writing. */ 2010 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 2004 AutoMultiWriteLock2 alock(&m->pVirtualBox->getMediaTreeLockHandle(), 2005 this->lockHandle() COMMA_LOCKVAL_SRC_POS); 2011 2006 2012 2007 HRESULT rc = S_OK; … … 2096 2091 { 2097 2092 alock.leave(); 2098 RTSemRWRequestRead(m->queryInfoSem, RT_INDEFINITE_WAIT); 2099 RTSemRWReleaseRead(m->queryInfoSem); 2093 { 2094 AutoReadLock qlock(m->queryInfoSem COMMA_LOCKVAL_SRC_POS); 2095 } 2100 2096 alock.enter(); 2101 2097 } … … 2203 2199 { 2204 2200 alock.leave(); 2205 RTSemRWRequestRead(m->queryInfoSem, RT_INDEFINITE_WAIT); 2206 RTSemRWReleaseRead(m->queryInfoSem); 2201 { 2202 AutoReadLock qlock(m->queryInfoSem COMMA_LOCKVAL_SRC_POS); 2203 } 2207 2204 alock.enter(); 2208 2205 } … … 3761 3758 * Constructs a medium lock list for this medium. The lock is not taken. 3762 3759 * 3763 * @note Locks the medium tree for reading.3760 * @note Caller must lock the medium tree for writing. 3764 3761 * 3765 3762 * @param fFailIfInaccessible If true, this fails with an error if a medium is inaccessible. If false, … … 3775 3772 MediumLockList &mediumLockList) 3776 3773 { 3774 // Medium::queryInfo needs write lock 3775 Assert(m->pVirtualBox->getMediaTreeLockHandle().isWriteLockOnCurrentThread()); 3776 3777 3777 AutoCaller autoCaller(this); 3778 3778 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 3779 3779 3780 3780 HRESULT rc = S_OK; 3781 3782 /* we access parent medium objects */3783 AutoReadLock treeLock(m->pVirtualBox->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);3784 3781 3785 3782 /* paranoid sanity checking if the medium has a to-be parent medium */ … … 3797 3794 while (!pMedium.isNull()) 3798 3795 { 3799 // need write lock for RefreshStateif medium is inaccessible3796 // need write lock for queryInfo if medium is inaccessible 3800 3797 AutoWriteLock alock(pMedium COMMA_LOCKVAL_SRC_POS); 3801 3798 … … 3806 3803 if (mediumState == MediumState_Inaccessible) 3807 3804 { 3808 rc = pMedium-> RefreshState(&mediumState);3805 rc = pMedium->queryInfo(false /* fSetImageId */, false /* fSetParentId */); 3809 3806 if (FAILED(rc)) return rc; 3810 3807 3808 mediumState = pMedium->getState(); 3811 3809 if (mediumState == MediumState_Inaccessible) 3812 3810 { … … 5254 5252 * accessibility. 5255 5253 * 5256 * @note Locks medium tree for reading and writing (for new diff media checked5257 * for the first time). Locks mParent for reading. Locks this object for5258 * 5254 * @note Caller must hold medium tree for writing. 5255 * 5256 * @note Locks mParent for reading. Locks this object for writing. 5259 5257 * 5260 5258 * @param fSetImageId Whether to reset the UUID contained in the image file to the UUID in the medium instance data (see SetIDs()) … … 5264 5262 HRESULT Medium::queryInfo(bool fSetImageId, bool fSetParentId) 5265 5263 { 5264 Assert(m->pVirtualBox->getMediaTreeLockHandle().isWriteLockOnCurrentThread()); 5266 5265 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 5267 5266 … … 5285 5284 { 5286 5285 alock.leave(); 5287 vrc = RTSemRWRequestRead(m->queryInfoSem, RT_INDEFINITE_WAIT);5288 RTSemRWReleaseRead(m->queryInfoSem);5289 AssertRC(vrc);5286 { 5287 AutoReadLock qlock(m->queryInfoSem COMMA_LOCKVAL_SRC_POS); 5288 } 5290 5289 alock.enter(); 5291 5290 } … … 5350 5349 * violation: here it would be requesting the object lock (at the beginning 5351 5350 * of the method), then SemRW, and below the other way round. */ 5352 vrc = RTSemRWRequestWrite(m->queryInfoSem, RT_INDEFINITE_WAIT); 5353 AssertRCReturn(vrc, E_FAIL); 5351 AutoWriteLock qlock(m->queryInfoSem COMMA_LOCKVAL_SRC_POS); 5354 5352 5355 5353 try … … 5583 5581 5584 5582 /* unblock anyone waiting for the queryInfo results */ 5585 RTSemRWReleaseWrite(m->queryInfoSem);5583 qlock.release(); 5586 5584 m->queryInfoRunning = false; 5587 5585
Note:
See TracChangeset
for help on using the changeset viewer.