Changeset 25524 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Dec 20, 2009 4:56:30 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 56197
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/posix/semrw-posix.cpp
r25498 r25524 73 73 /** The usual magic. (RTSEMRW_MAGIC) */ 74 74 uint32_t u32Magic; 75 /* Alignment padding. */ 76 uint32_t u32Padding; 75 /** The number of readers. 76 * (For preventing screwing up the lock on linux). */ 77 uint32_t volatile cReaders; 77 78 /** Number of write recursions. */ 78 79 uint32_t cWrites; … … 112 113 if (!rc) 113 114 { 114 pThis->u32Magic = RTSEMRW_MAGIC;115 pThis-> u32Padding= 0;116 pThis->cWrites = 0;115 pThis->u32Magic = RTSEMRW_MAGIC; 116 pThis->cReaders = 0; 117 pThis->cWrites = 0; 117 118 pThis->cWriterReads = 0; 118 pThis->Writer = (pthread_t)-1;119 pThis->Writer = (pthread_t)-1; 119 120 #ifdef RTSEMRW_STRICT 120 121 RTLockValidatorRecInit(&pThis->ValidatorWrite, NIL_RTLOCKVALIDATORCLASS, RTLOCKVALIDATOR_SUB_CLASS_NONE, NULL, pThis); … … 149 150 VERR_INVALID_HANDLE); 150 151 Assert(pThis->Writer == (pthread_t)-1); 152 Assert(!pThis->cReaders); 151 153 Assert(!pThis->cWrites); 152 154 Assert(!pThis->cWriterReads); … … 272 274 } 273 275 276 ASMAtomicIncU32(&pThis->cReaders); 274 277 #ifdef RTSEMRW_STRICT 275 278 RTLockValidatorAddReadOwner(&pThis->ValidatorRead, hThreadSelf, pSrcPos); … … 323 326 return rc9; 324 327 #endif 328 #ifdef RT_OS_LINUX /* glibc (at least 2.8) may screw up when unlocking a lock we don't own. */ 329 if (ASMAtomicReadU32(&pThis->cReaders) == 0) 330 { 331 AssertMsgFailed(("Not owner of %p\n", pThis)); 332 return VERR_NOT_OWNER; 333 } 334 #endif 335 ASMAtomicDecU32(&pThis->cReaders); 325 336 int rc = pthread_rwlock_unlock(&pThis->RWLock); 326 337 if (rc) 327 338 { 339 ASMAtomicIncU32(&pThis->cReaders); 328 340 AssertMsgFailed(("Failed read unlock read-write sem %p, rc=%d.\n", RWSem, rc)); 329 341 return RTErrConvertFromErrno(rc); … … 426 438 ATOMIC_SET_PTHREAD_T(&pThis->Writer, Self); 427 439 pThis->cWrites = 1; 440 Assert(!pThis->cReaders); 428 441 #ifdef RTSEMRW_STRICT 429 442 RTLockValidatorSetOwner(&pThis->ValidatorWrite, hThreadSelf, pSrcPos);
Note:
See TracChangeset
for help on using the changeset viewer.