VirtualBox

Changeset 8726 in vbox


Ignore:
Timestamp:
May 8, 2008 7:48:48 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
30675
Message:

Main/AutoLock: Sanity.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
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