Diffs attached
30.01.2015 17:49, [email protected] пишет:
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/13789 .
The idea is that functions /Medium::removeRegistry()/ and
/Medium::addRegistry()/ themselves take write locks on mediums, so we
get read lock only for /Medium::getAnyMachineBackref()/ call in
/VirtualBox::unregisterMachine()/ function. Also we release read lock
on medium after we got its parent and before we are going to iterate
through parents in /Machine::detachAllMedia()/ function.
Regards,
Alexander
--- old/MachineImpl.cpp 2015-01-30 17:17:38.000000000 +0300
+++ new/MachineImpl.cpp 2015-01-30 17:22:32.739700674 +0300
@@ -11785,6 +11785,7 @@
{
llMedia.push_back(pMedium);
ComObjPtr<Medium> pParent = pMedium->getParent();
+ lock.release();
/*
* Search for medias which are not attached to any machine, but
* in the chain to an attached disk. Mediums are only consided
--- old/VirtualBoxImpl.cpp 2015-01-30 17:17:38.000000000 +0300
+++ new/VirtualBoxImpl.cpp 2015-01-30 17:20:21.000000000 +0300
@@ -4666,24 +4666,22 @@
ComObjPtr<Medium> &pMedium = *it;
AutoCaller medCaller(pMedium);
if (FAILED(medCaller.rc())) return medCaller.rc();
- AutoWriteLock mlock(pMedium COMMA_LOCKVAL_SRC_POS);
-
if (pMedium->removeRegistry(id, true /* fRecurse */))
{
// machine ID was found in base medium's registry list:
// move this base image and all its children to another registry then
// 1) first, find a better registry to add things to
+ AutoReadLock mlock(pMedium COMMA_LOCKVAL_SRC_POS);
const Guid *puuidBetter = pMedium->getAnyMachineBackref();
+ mlock.release();
if (puuidBetter)
{
// 2) better registry found: then use that
pMedium->addRegistry(*puuidBetter, true /* fRecurse */);
// 3) and make sure the registry is saved below
- mlock.release();
tlock.release();
markRegistryModified(*puuidBetter);
tlock.acquire();
- mlock.release();
}
}
}
_______________________________________________
vbox-dev mailing list
[email protected]
https://www.virtualbox.org/mailman/listinfo/vbox-dev