- Timestamp:
- Mar 6, 2023 6:56:23 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 156169
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/MediumImpl.h
r98291 r98846 117 117 MediumVariant_T i_getVariant() const; 118 118 bool i_isHostDrive() const; 119 bool i_isClosing() const; 119 120 const Utf8Str& i_getLocationFull() const; 120 121 const Utf8Str& i_getFormat() const; -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r98352 r98846 1448 1448 break; 1449 1449 hrc = aVirtualBox->i_registerMedium(pActualMedium, &pActualMedium, mediaTreeLock, true /*fCalledFromMediumInit*/); 1450 if (FAILED(hrc)) 1451 break; 1452 1453 if (pActualMedium == pMedium) 1450 if (SUCCEEDED(hrc) && pActualMedium == pMedium) 1454 1451 { 1455 1452 /* It is a truly new medium, remember details for cleanup. */ … … 1473 1470 pMedium.setNull(); 1474 1471 mediaTreeLock.acquire(); 1472 1473 if (FAILED(hrc)) 1474 break; 1475 1475 } 1476 1476 … … 4386 4386 4387 4387 /** 4388 * Internal method which returns true if this medium is in the process of being closed. 4389 * @return 4390 */ 4391 bool Medium::i_isClosing() const 4392 { 4393 return m->fClosing; 4394 } 4395 4396 /** 4388 4397 * Internal method to return the medium's full location. Must have caller + locking! 4389 4398 * @return … … 5703 5712 } 5704 5713 5705 // Keep the locks held until after uninit, as otherwise the consistency5706 // of the medium tree cannot be guaranteed.5707 5714 uninit(); 5708 5715 -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r98836 r98846 5110 5110 strLocationFull = pMedium->i_getLocationFull(); 5111 5111 pParent = pMedium->i_getParent(); 5112 5113 /* 5114 * If a separate thread has called Medium::close() for this medium at the same 5115 * time as this i_registerMedium() call then there is a window of opportunity in 5116 * Medium::i_close() where the media tree lock is dropped before calling 5117 * Medium::uninit() (which reacquires the lock) that we can end up here attempting 5118 * to register a medium which is in the process of being closed. In addition, if 5119 * this is a differencing medium and Medium::close() is in progress for one its 5120 * parent media then we are similarly operating on a media registry in flux. In 5121 * either case registering a medium just before calling Medium::uninit() will 5122 * lead to an inconsistent media registry so bail out here since Medium::close() 5123 * got to this medium (or one of its parents) first. 5124 */ 5125 if (devType == DeviceType_HardDisk) 5126 { 5127 ComObjPtr<Medium> pTmpMedium = pMedium; 5128 while (pTmpMedium.isNotNull()) 5129 { 5130 AutoCaller mediumAC(pTmpMedium); 5131 if (FAILED(mediumAC.hrc())) return mediumAC.hrc(); 5132 AutoReadLock mlock(pTmpMedium COMMA_LOCKVAL_SRC_POS); 5133 5134 if (pTmpMedium->i_isClosing()) 5135 return setError(E_INVALIDARG, 5136 tr("Cannot register %s '%s' {%RTuuid} because it is in the process of being closed"), 5137 pszDevType, 5138 pTmpMedium->i_getLocationFull().c_str(), 5139 pTmpMedium->i_getId().raw()); 5140 5141 pTmpMedium = pTmpMedium->i_getParent(); 5142 } 5143 } 5112 5144 } 5113 5145
Note:
See TracChangeset
for help on using the changeset viewer.