From 764f8335d03e05b1ddc8fd7f835978447b799947 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 8 Feb 2013 08:58:28 +0100 Subject: [PATCH] base: reset _last_applicant variable Fixes #647 --- base/src/base/lock/lock.cc | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/base/src/base/lock/lock.cc b/base/src/base/lock/lock.cc index fb0c7a207..021fe29b8 100644 --- a/base/src/base/lock/lock.cc +++ b/base/src/base/lock/lock.cc @@ -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; } }