Hello!
We would like to contribute to VirtualBox under MIT license. We send our
changes to fix bug described at https://www.virtualbox.org/ticket/13801 .
The idea is that there is no need to hold write lock on parent medium to
change its locking type. In current version we unlock all session locked
list first and only then we update locking type. But in this case only
element of /pMediumLockList/ is changed, not /Medium/ object. May be
parent write-locking code left after old version, where parent lock type
updating looked like this (version /3.1.8/):
ComObjPtr<Medium> parent = pMedium->getParent();
/* make the relock atomic */
AutoWriteLock parentLock (parent);
rc = parent->UnlockWrite(NULL);
AssertComRC(rc);
rc = parent->LockRead(NULL);
AssertComRC(rc);
Regards,
Alexander
--- old/MachineImpl.cpp 2015-01-30 17:17:38.000000000 +0300
+++ new/MachineImpl.cpp 2015-01-30 17:23:12.515701224 +0300
@@ -11882,9 +11882,6 @@
&& pAttach->getType() == DeviceType_HardDisk
)
{
- ComObjPtr<Medium> parent = pMedium->getParent();
- AutoWriteLock parentLock(parent COMMA_LOCKVAL_SRC_POS);
-
/* update the appropriate lock list */
MediumLockList *pMediumLockList;
rc = mData->mSession.mLockedMedia.Get(pAttach, pMediumLockList);
@@ -11898,7 +11895,7 @@
AssertComRC(rc);
fMediaNeedsLocking = true;
}
- rc = pMediumLockList->Update(parent, false);
+ rc = pMediumLockList->Update(pMedium->getParent(), false);
AssertComRC(rc);
rc = pMediumLockList->Append(pMedium, true);
AssertComRC(rc);
_______________________________________________
vbox-dev mailing list
[email protected]
https://www.virtualbox.org/mailman/listinfo/vbox-dev