fix racy assert in SharedMutex
authorNathan Bronson <ngbronson@fb.com>
Wed, 22 Jul 2015 22:14:58 +0000 (15:14 -0700)
committerfacebook-github-bot-4 <folly-bot@fb.com>
Wed, 22 Jul 2015 23:22:11 +0000 (16:22 -0700)
commit7334598fed1fa92effebc904ec2a44d7e800c2b6
tree82052a0b53f6a54d0dc3c172b057654fb77c488d
parentcd46406972560ba52a606cb21789b969fe9188c8
fix racy assert in SharedMutex

Summary: SharedMutex purposely allows the inline reader count to underflow in some
situations while preserving proper locking behavior (the inline reader
count is only trusted if all deferred locks have been applied), but there
was an additional way that this could occur that wasn't documented or
allowed by the asserts.  The effect was a false positive assert in rare
conditions or the possibility of losing track of a deferred lock slot.
This diff fixes both the over-aggressive assert and the potential loss
of the shared slot.  If the assert didn't fire for you then this diff
won't change the correctness of your program.

Reviewed By: @yfeldblum

Differential Revision: D2269018
folly/SharedMutex.h
folly/test/SharedMutexTest.cpp