base: fix race in multiple lock.unlock() calls

Fixes #2122
This commit is contained in:
Alexander Boettcher 2016-10-07 19:59:18 +02:00 committed by Christian Helmuth
parent 9013ca5364
commit c99729093a
1 changed files with 5 additions and 1 deletions

View File

@ -146,12 +146,16 @@ void Cancelable_lock::unlock()
/* transfer lock ownership to next applicant and wake him up */
_owner = *next_owner;
/* make copy since _owner may change outside spinlock ! */
Applicant owner = *next_owner;
if (_last_applicant == next_owner)
_last_applicant = &_owner;
spinlock_unlock(&_spinlock_state);
_owner.wake_up();
owner.wake_up();
} else {