VirtualBox

Changeset 28582 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Apr 22, 2010 8:09:21 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
60412
Message:

Main/MediumLock: Make updating the required lock type available while locked. Simplifies use a lot and not that much more work. As a side effect minimizes the risk of losing the lock.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MediumLock.cpp

    r28556 r28582  
    5050HRESULT MediumLock::UpdateLock(bool aLockWrite)
    5151{
    52     if (mIsLocked)
    53         return VBOX_E_INVALID_OBJECT_STATE;
     52    if (aLockWrite == mLockWrite)
     53        return S_OK;
     54    if (mIsLocked)
     55    {
     56        HRESULT rc = Unlock();
     57        if (FAILED(rc))
     58        {
     59            Lock();
     60            return rc;
     61        }
     62        mLockWrite = aLockWrite;
     63        rc = Lock();
     64        if (FAILED(rc))
     65        {
     66            mLockWrite = !mLockWrite;
     67            Lock();
     68            return rc;
     69        }
     70        return S_OK;
     71    }
     72
    5473    mLockWrite = aLockWrite;
    5574    return S_OK;
  • trunk/src/VBox/Main/include/MediumLock.h

    r28556 r28582  
    7474
    7575    /**
    76      * Update a medium lock description
    77      *
    78      * @note May be only used in unlocked state.
     76     * Update a medium lock description.
     77     *
     78     * @note May be used in locked state.
    7979     *
    8080     * @return COM status code
     
    190190
    191191    /**
    192      * Clear all medium lock declaration.
     192     * Clear all medium lock declarations.
    193193     *
    194194     * @note Implicitly unlocks all locks.
Note: See TracChangeset for help on using the changeset viewer.

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