VirtualBox

Ignore:
Timestamp:
May 7, 2008 3:23:25 PM (17 years ago)
Author:
vboxsync
Message:

Use must use atomic compare-and-exchange logic here to be 100% correct.

File:
1 edited

Legend:

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

    r8155 r8665  
    6666RWLockHandle *VirtualBoxBaseNEXT_base::lockHandle() const
    6767{
    68     /* lasy initialization */
    69     if (!mObjectLock)
    70         mObjectLock = new RWLockHandle;
     68    /* lazy initialization */
     69    if (RT_UNLIKELY(!mObjectLock))
     70    {
     71        AssertCompile (sizeof (RWLockHandle *) == sizeof (void *));
     72        RWLockHandle *objLock = new RWLockHandle;
     73        if (!ASMAtomicCmpXchgPtr ((void * volatile *) &mObjectLock, objLock, NULL))
     74        {
     75            delete objLock;
     76            objLock = (RWLockHandle *) ASMAtomicReadPtr ((void * volatile *) &mObjectLock);
     77        }
     78        return objLock;
     79    }
    7180    return mObjectLock;
    7281}
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