base: reset _last_applicant variable

Fixes #647
This commit is contained in:
Alexander Boettcher 2013-02-08 08:58:28 +01:00 committed by Norman Feske
parent ee8eea9330
commit 764f8335d0
1 changed files with 11 additions and 18 deletions

View File

@ -107,24 +107,17 @@ void Cancelable_lock::lock()
*/
spinlock_lock(&_spinlock_state);
if (_owner != myself) {
/* check if we are the applicant to be waken up next */
Applicant *a = _owner.applicant_to_wake_up();
if (a && (*a == myself)) {
_owner.applicant_to_wake_up(myself.applicant_to_wake_up());
/* otherwise, go through the list of remaining applicants */
} else {
for (; a; a = a->applicant_to_wake_up()) {
/* remove reference to ourself from the applicants list */
if (a->applicant_to_wake_up() == &myself) {
a->applicant_to_wake_up(myself.applicant_to_wake_up());
break;
}
/*
* Check if we are the applicant to be waken up next,
* otherwise, go through the list of remaining applicants
*/
for (Applicant *a = &_owner; a; a = a->applicant_to_wake_up()) {
/* remove reference to ourself from the applicants list */
if (a->applicant_to_wake_up() == &myself) {
a->applicant_to_wake_up(myself.applicant_to_wake_up());
if (_last_applicant == &myself)
_last_applicant = a;
break;
}
}