Skip to content

Commit

Permalink
Fix deadlock in condition_variable_any with stop_token (#2220)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephan T. Lavavej <[email protected]>
  • Loading branch information
AlexGuteniev and StephanTLavavej authored Oct 20, 2021
1 parent bb210e7 commit 066c172
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion stl/inc/condition_variable
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ public:
}

_Unlock_guard<_Lock> _Unlock_outer{_Lck};
unique_lock<mutex> _Guard_unlocks_before_locking_outer{_STD move(_Guard)};

const auto _Now = _Clock::now();
if (_Now >= _Abs_time) {
break;
Expand All @@ -223,7 +225,7 @@ public:
_CSTD xtime _Tgt;
(void) _To_xtime_10_day_clamped(_Tgt, _Rel_time);
const int _Res = _Cnd_timedwait(_Mycnd(), _Myptr->_Mymtx(), &_Tgt);
_Guard.unlock();
_Guard_unlocks_before_locking_outer.unlock();

switch (_Res) {
case _Thrd_timedout:
Expand Down

0 comments on commit 066c172

Please sign in to comment.