VirtualBox

Changeset 57076 in vbox for trunk


Ignore:
Timestamp:
Jul 24, 2015 6:43:41 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: 7948: Medium-enumeration handler cleanup deadlock: Do not lock-for-read (since locking-for-write is possible), just try instead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r57045 r57076  
    147147# include <QNetworkProxy>
    148148#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    149 #include <QReadLocker>
    150149#include <QSettings>
    151150#include <QStyleOptionSpinBox>
     
    15481547void VBoxGlobal::createMedium(const UIMedium &medium)
    15491548{
    1550     /* Create medium in medium-enumerator: */
    1551     QReadLocker cleanupRacePreventor(&m_mediumEnumeratorDtorRwLock);
    1552     if (m_pMediumEnumerator)
    1553         m_pMediumEnumerator->createMedium(medium);
     1549    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
     1550    {
     1551        /* Create medium in medium-enumerator: */
     1552        if (m_pMediumEnumerator)
     1553            m_pMediumEnumerator->createMedium(medium);
     1554        m_mediumEnumeratorDtorRwLock.unlock();
     1555    }
    15541556}
    15551557
    15561558void VBoxGlobal::deleteMedium(const QString &strMediumID)
    15571559{
    1558     /* Delete medium from medium-enumerator: */
    1559     QReadLocker cleanupRacePreventor(&m_mediumEnumeratorDtorRwLock);
    1560     if (m_pMediumEnumerator)
    1561         m_pMediumEnumerator->deleteMedium(strMediumID);
     1560    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
     1561    {
     1562        /* Delete medium from medium-enumerator: */
     1563        if (m_pMediumEnumerator)
     1564            m_pMediumEnumerator->deleteMedium(strMediumID);
     1565        m_mediumEnumeratorDtorRwLock.unlock();
     1566    }
    15621567}
    15631568
     
    17341739        return;
    17351740
    1736     /* Redirect request to medium-enumerator: */
    1737     QReadLocker cleanupRacePreventor(&m_mediumEnumeratorDtorRwLock);
    1738     if (m_pMediumEnumerator)
    1739         m_pMediumEnumerator->enumerateMediums();
     1741    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
     1742    {
     1743        /* Redirect request to medium-enumerator: */
     1744        if (m_pMediumEnumerator)
     1745            m_pMediumEnumerator->enumerateMediums();
     1746        m_mediumEnumeratorDtorRwLock.unlock();
     1747    }
    17401748}
    17411749
     
    17491757UIMedium VBoxGlobal::medium(const QString &strMediumID) const
    17501758{
    1751     /* Redirect call to medium-enumerator: */
    1752     QReadLocker cleanupRacePreventor(&m_mediumEnumeratorDtorRwLock);
    1753     if (m_pMediumEnumerator)
    1754         return m_pMediumEnumerator->medium(strMediumID);
     1759    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
     1760    {
     1761        /* Redirect call to medium-enumerator: */
     1762        UIMedium result;
     1763        if (m_pMediumEnumerator)
     1764            result = m_pMediumEnumerator->medium(strMediumID);
     1765        m_mediumEnumeratorDtorRwLock.unlock();
     1766        return result;
     1767    }
    17551768    return UIMedium();
    17561769}
     
    17581771QList<QString> VBoxGlobal::mediumIDs() const
    17591772{
    1760     /* Redirect call to medium-enumerator: */
    1761     QReadLocker cleanupRacePreventor(&m_mediumEnumeratorDtorRwLock);
    1762     if (m_pMediumEnumerator)
    1763         return m_pMediumEnumerator->mediumIDs();
     1773    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
     1774    {
     1775        /* Redirect call to medium-enumerator: */
     1776        QList<QString> result;
     1777        if (m_pMediumEnumerator)
     1778            result = m_pMediumEnumerator->mediumIDs();
     1779        m_mediumEnumeratorDtorRwLock.unlock();
     1780        return result;
     1781    }
    17641782    return QList<QString>();
    17651783}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette