|
As for why the hit count may exceed 2, it's because this hit count can potentially be incremented in both the shouldFail() check and in the pauseWhileSet() call, and a thread may still increment the hit count even if another thread has already disabled the failpoint. The order of events needed to make this happen is:
- T1 calls shouldFail() -> calls _evaluateByMode() -> _modeValue decremented from 2 to 1 -> hit count incremented to 1
- T1 calls pauseWhileSet(), -> calls _evaluateByMode()
- T2 calls shouldFail() -> calls _evaluateByMode()
- T1 (in _evaluateByMode()) decrements _modeValue to 0, disabling the failpoint -> hit count incremented to 2
- T2 (also in _evaluateByMode()) decrements _modeValue to -1, disabling the failpoint -> hit count incremented to 3
|