VirtualBox

Changeset 8726

Show
Ignore:
Timestamp:
05/08/08 21:48:48 (2 months ago)
Author:
vboxsync
Message:

Main/AutoLock: Sanity.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/VBox/Main/AutoLock.cpp

    r8664 r8726  
    291291    RTCritSectEnter (&mCritSect); 
    292292 
     293    RTNATIVETHREAD threadSelf = RTThreadNativeSelf(); 
     294 
    293295    Assert (mWriteLockLevel != 0 /* unlockWrite() w/o preceding lockWrite()? */); 
    294296    if (mWriteLockLevel != 0) 
    295297    { 
    296         -- mWriteLockLevel; 
    297         if (mWriteLockLevel == 0) 
    298         { 
    299             Assert (mSelfReadLockCount == 0 
    300                     /* mixed unlockWrite()/unlockRead() order? */); 
    301  
    302             mWriteLockThread = NIL_RTNATIVETHREAD; 
    303  
    304             /* no write locks, let writers go if there are any (top priority), 
    305              * otherwise let readers go if there are any */ 
    306             if (mWriteLockPending != 0) 
    307                 RTSemEventSignal (mGoWriteSem); 
    308             else if (mReadLockCount != 0) 
    309                 RTSemEventMultiSignal (mGoReadSem); 
     298        Assert (mWriteLockThread == threadSelf 
     299                /* unlockWrite() w/o preceding lockWrite()? */); 
     300        if (mWriteLockThread == threadSelf) 
     301        { 
     302            -- mWriteLockLevel; 
     303            if (mWriteLockLevel == 0) 
     304            { 
     305                Assert (mSelfReadLockCount == 0 
     306                        /* mixed unlockWrite()/unlockRead() order? */); 
     307 
     308                mWriteLockThread = NIL_RTNATIVETHREAD; 
     309 
     310                /* no write locks, let writers go if there are any (top priority), 
     311                 * otherwise let readers go if there are any */ 
     312                if (mWriteLockPending != 0) 
     313                    RTSemEventSignal (mGoWriteSem); 
     314                else if (mReadLockCount != 0) 
     315                    RTSemEventMultiSignal (mGoReadSem); 
    310316 
    311317# ifdef DEBUG 
    312             RTTHREAD iprtThreadSelf = RTThreadSelf(); 
    313             if (iprtThreadSelf != NIL_RTTHREAD) 
    314                 RTThreadWriteLockDec (iprtThreadSelf); 
    315 # endif 
     318                RTTHREAD iprtThreadSelf = RTThreadSelf(); 
     319                if (iprtThreadSelf != NIL_RTTHREAD) 
     320                    RTThreadWriteLockDec (iprtThreadSelf); 
     321# endif 
     322            } 
    316323        } 
    317324    } 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy