[haiku-commits] haiku: hrev53337 - src/system/kernel

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 3 Aug 2019 20:31:58 -0400 (EDT)

hrev53337 adds 1 changeset to branch 'master'
old head: 2f1e2ae469ccb1657cc506db06de8de33b89b874
new head: 287428271dd5329c9d84758c43fa350033818a3e
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=287428271dd5+%5E2f1e2ae469cc

----------------------------------------------------------------------------

287428271dd5: kernel/condition_variable: Acquire and release locks in the right 
order.
  
  Should fix #15223.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev53337
Commit:      287428271dd5329c9d84758c43fa350033818a3e
URL:         https://git.haiku-os.org/haiku/commit/?id=287428271dd5
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sun Aug  4 00:31:41 2019 UTC

Ticket:      https://dev.haiku-os.org/ticket/15223

----------------------------------------------------------------------------

1 file changed, 3 insertions(+), 1 deletion(-)
src/system/kernel/condition_variable.cpp | 4 +++-

----------------------------------------------------------------------------

diff --git a/src/system/kernel/condition_variable.cpp 
b/src/system/kernel/condition_variable.cpp
index 16ac6b809c..c33882e329 100644
--- a/src/system/kernel/condition_variable.cpp
+++ b/src/system/kernel/condition_variable.cpp
@@ -325,11 +325,12 @@ ConditionVariable::_NotifyLocked(bool all, status_t 
result)
        // entering Wait() and acquiring its own lock, and then acquiring ours.
        while (ConditionVariableEntry* entry = fEntries.RemoveHead()) {
                release_spinlock(&fLock);
+               acquire_spinlock(&entry->fLock);
 
-               SpinLocker _(entry->fLock);
                entry->fVariable = NULL;
 
                if (entry->fWaitStatus <= 0) {
+                       release_spinlock(&entry->fLock);
                        acquire_spinlock(&fLock);
                        continue;
                }
@@ -341,6 +342,7 @@ ConditionVariable::_NotifyLocked(bool all, status_t result)
 
                entry->fWaitStatus = result;
 
+               release_spinlock(&entry->fLock);
                acquire_spinlock(&fLock);
 
                if (!all)


Other related posts: