Changeset 73858 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Aug 23, 2018 1:35:07 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r73003 r73858 1600 1600 autoCaller.release(); 1601 1601 1602 // locking: we need the tree lock first because we access parent pointers 1603 // and we need to write-lock the media involved 1604 AutoWriteLock treeLock(m->pVirtualBox->i_getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 1605 1606 autoCaller.add(); 1607 AssertComRCThrowRC(autoCaller.rc()); 1608 1609 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1602 // to avoid redundant locking, which just takes a time, just call required functions. 1603 // the error will be just stored and will be reported after locks will be acquired again 1604 1605 const char *pszError = NULL; 1606 1610 1607 1611 1608 /* Build the lock list. */ 1612 alock.release();1613 autoCaller.release();1614 treeLock.release();1615 1609 rc = i_createMediumLockList(true /* fFailIfInaccessible */, 1616 1610 this /* pToLockWrite */, … … 1618 1612 NULL, 1619 1613 *pMediumLockList); 1620 treeLock.acquire(); 1614 if (FAILED(rc)) 1615 { 1616 pszError = tr("Failed to create medium lock list for '%s'"); 1617 } 1618 else 1619 { 1620 rc = pMediumLockList->Lock(); 1621 if (FAILED(rc)) 1622 pszError = tr("Failed to lock media '%s'"); 1623 } 1624 1625 // locking: we need the tree lock first because we access parent pointers 1626 // and we need to write-lock the media involved 1627 AutoWriteLock treeLock(m->pVirtualBox->i_getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 1628 1621 1629 autoCaller.add(); 1622 1630 AssertComRCThrowRC(autoCaller.rc()); 1623 alock.acquire(); 1631 1632 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1624 1633 1625 1634 if (FAILED(rc)) 1626 { 1627 throw setError(rc, 1628 tr("Failed to create medium lock list for '%s'"), 1629 i_getLocationFull().c_str()); 1630 } 1631 1632 alock.release(); 1633 autoCaller.release(); 1634 treeLock.release(); 1635 rc = pMediumLockList->Lock(); 1636 treeLock.acquire(); 1637 autoCaller.add(); 1638 AssertComRCThrowRC(autoCaller.rc()); 1639 alock.acquire(); 1640 1641 if (FAILED(rc)) 1642 { 1643 throw setError(rc, 1644 tr("Failed to lock media '%s'"), 1645 i_getLocationFull().c_str()); 1646 } 1635 throw setError(rc, pszError, i_getLocationFull().c_str()); 1647 1636 1648 1637 /* Set a new description */ 1649 if (SUCCEEDED(rc)) 1650 { 1651 m->strDescription = aDescription; 1652 } 1638 m->strDescription = aDescription; 1653 1639 1654 1640 // save the settings
Note:
See TracChangeset
for help on using the changeset viewer.