Skip to content

Commit

Permalink
Fix miscellaneous ReaderWriterLockSlim issues
Browse files Browse the repository at this point in the history
- Stop spinning for _myLock when deprioritized and the timeout expires, as deprioritized means the intended progress cannot be made on the RW lock

Fixes #13254:
- In the TryEnter* functions the conditions checked before the spin loop are now done inside the spin loop to account for reentrancy due to message pumping during a wait (including Sleep and WaitOne), during which the RW lock state may change.
  - Refactored condition checking in the spin loop to do some before and after the loop and some at the top of the loop, to minimize negative perf impact on the common fast paths
  - Exception cases are rechecked upon timeout in case of a state change
- An exception from GetThreadRWCount(dontAllocate: false) is accounted for. Upon OOM, it previously could have led to not exiting _myLock, hanging subsequent uses of the RW lock.
- When attempting to acquire a write lock, if the thread became a waiter and got signaled but failed to acquire the write lock, it now wakes up read waiters as they would otherwise be blocked by the write waiter. This was previously only handled for the case where the wait times out, it is now handled on all paths.
  • Loading branch information
kouvel committed Aug 18, 2017
1 parent f4d0d00 commit 87010a0
Show file tree
Hide file tree
Showing 2 changed files with 673 additions and 301 deletions.
Loading

0 comments on commit 87010a0

Please sign in to comment.