VirtualBox

Changeset 14665 in vbox


Ignore:
Timestamp:
Nov 26, 2008 10:50:00 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
39975
Message:

Main: Locking and sanity.

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

Legend:

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

    r14664 r14665  
    710710void BIOSSettings::commit()
    711711{
    712     AutoWriteLock alock (this);
     712    /* sanity */
     713    AutoCaller autoCaller (this);
     714    AssertComRCReturnVoid (autoCaller.rc());
     715
     716    /* sanity too */
     717    AutoCaller peerCaller (mPeer);
     718    AssertComRCReturnVoid (peerCaller.rc());
     719
     720    /* lock both for writing since we modify both (mPeer is "master" so locked
     721     * first) */
     722    AutoMultiWriteLock2 alock (mPeer, this);
     723
    713724    if (mData.isBackedUp())
    714725    {
     
    716727        if (mPeer)
    717728        {
    718             // attach new data to the peer and re-share it
     729            /* attach new data to the peer and reshare it */
    719730            AutoWriteLock peerlock (mPeer);
    720731            mPeer->mData.attach (mData);
     
    725736void BIOSSettings::copyFrom (BIOSSettings *aThat)
    726737{
    727     AutoWriteLock alock (this);
    728 
    729     // this will back up current data
     738    AssertReturnVoid (aThat != NULL);
     739
     740    /* sanity */
     741    AutoCaller autoCaller (this);
     742    AssertComRCReturnVoid (autoCaller.rc());
     743
     744    /* sanity too */
     745    AutoCaller thatCaller (aThat);
     746    AssertComRCReturnVoid (thatCaller.rc());
     747
     748    /* peer is not modified, lock it for reading (aThat is "master" so locked
     749     * first) */
     750    AutoMultiLock2 alock (aThat->rlock(), this->wlock());
     751
     752    /* this will back up current data */
    730753    mData.assignCopy (aThat->mData);
    731754}
     
    733756void BIOSSettings::applyDefaults (GuestOSType *aOsType)
    734757{
    735     if (!aOsType)
    736         return;
     758    AssertReturnVoid (aOsType != NULL);
     759
     760    /* sanity */
     761    AutoCaller autoCaller (this);
     762    AssertComRCReturnVoid (autoCaller.rc());
     763
     764    AutoWriteLock alock (this);
    737765
    738766    /* Initialize default BIOS settings here */
  • trunk/src/VBox/Main/NetworkAdapterImpl.cpp

    r14664 r14665  
    13021302void NetworkAdapter::applyDefaults (GuestOSType *aOsType)
    13031303{
    1304     if (!aOsType)
    1305         return;
     1304    AssertReturnVoid (aOsType != NULL);
     1305
     1306    /* sanity */
     1307    AutoCaller autoCaller (this);
     1308    AssertComRCReturnVoid (autoCaller.rc());
     1309
     1310    AutoWriteLock alock (this);
    13061311
    13071312    bool e1000enabled = false;
    13081313#ifdef VBOX_WITH_E1000
    1309     e1000enabled = true;   
     1314    e1000enabled = true;
    13101315#endif // VBOX_WITH_E1000
    13111316
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