VirtualBox

Changeset 78072 in vbox


Ignore:
Timestamp:
Apr 10, 2019 10:04:06 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
129928
Message:

Recording/Main: Settings locking fixes.

Location:
trunk/src/VBox/Main/src-server
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r77910 r78072  
    19471947HRESULT Machine::getRecordingSettings(ComPtr<IRecordingSettings> &aRecordingSettings)
    19481948{
    1949     /* mRecordingSettings is constant during life time, no need to lock */
     1949    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     1950
    19501951    aRecordingSettings = mRecordingSettings;
    19511952
  • trunk/src/VBox/Main/src-server/RecordingScreenSettingsImpl.cpp

    r78070 r78072  
    140140    unconst(m->pPeer)   = aThat;
    141141
    142     AutoWriteLock thatlock(aThat COMMA_LOCKVAL_SRC_POS);
     142    AutoCaller thatCaller(aThat);
     143    AssertComRCReturnRC(thatCaller.rc());
     144
     145    AutoReadLock thatlock(aThat COMMA_LOCKVAL_SRC_POS);
    143146
    144147    m->uScreenId = aThat->m->uScreenId;
     
    183186    /* mPeer is left null. */
    184187
    185     AutoWriteLock thatlock(aThat COMMA_LOCKVAL_SRC_POS);
     188    AutoCaller thatCaller(aThat);
     189    AssertComRCReturnRC(thatCaller.rc());
     190
     191    AutoReadLock thatlock(aThat COMMA_LOCKVAL_SRC_POS);
    186192
    187193    m->uScreenId = aThat->m->uScreenId;
  • trunk/src/VBox/Main/src-server/RecordingSettingsImpl.cpp

    r78071 r78072  
    100100 *  @note This object must be destroyed before the original object
    101101 *  it shares data with is destroyed.
     102 *
     103 *  @note Locks @a aThat object for reading.
    102104 */
    103105HRESULT RecordingSettings::init(Machine *aParent, RecordingSettings *aThat)
     
    117119    unconst(m->pPeer)    = aThat;
    118120
    119     AutoWriteLock thatlock(aThat COMMA_LOCKVAL_SRC_POS);
     121    AutoCaller thatCaller(aThat);
     122    AssertComRCReturnRC(thatCaller.rc());
     123
     124    AutoReadLock thatlock(aThat COMMA_LOCKVAL_SRC_POS);
    120125
    121126    m->bd.share(aThat->m->bd);
     
    132137 *  (a kind of copy constructor). This object makes a private copy of data
    133138 *  of the original object passed as an argument.
     139 *
     140 *  @note Locks @a aThat object for reading.
    134141 */
    135142HRESULT RecordingSettings::initCopy(Machine *aParent, RecordingSettings *aThat)
     
    149156    // mPeer is left null
    150157
    151     AutoWriteLock thatlock(aThat COMMA_LOCKVAL_SRC_POS);
     158    AutoReadLock thatlock(aThat COMMA_LOCKVAL_SRC_POS);
    152159
    153160    m->bd.attachCopy(aThat->m->bd);
     
    201208HRESULT RecordingSettings::setEnabled(BOOL enable)
    202209{
    203     LogFlowThisFuncEnter();
     210    /* the machine needs to be mutable */
     211    AutoMutableOrSavedOrRunningStateDependency adep(m->pMachine);
     212    if (FAILED(adep.rc())) return adep.rc();
    204213
    205214    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    215224
    216225        alock.release();
     226
    217227        rc = m->pMachine->i_onRecordingChange(enable);
    218228        if (FAILED(rc))
     
    232242            m->pMachine->i_setModified(Machine::IsModified_Recording);
    233243
     244            /* Make sure to release the mutable dependency lock from above before
     245             * actually saving the settings. */
     246            adep.release();
     247
    234248            /** Save settings if online - @todo why is this required? -- @bugref{6818} */
    235249            if (Global::IsOnline(m->pMachine->i_getMachineState()))
     
    492506void RecordingSettings::i_rollback()
    493507{
     508    /* sanity */
     509    AutoCaller autoCaller(this);
     510    AssertComRCReturnVoid(autoCaller.rc());
     511
    494512    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    495513    m->bd.rollback();
     
    516534        {
    517535            /* attach new data to the peer and reshare it */
    518             AutoWriteLock peerlock(m->pPeer COMMA_LOCKVAL_SRC_POS);
    519536            m->pPeer->m->bd.attach(m->bd);
    520537        }
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