From 2231e129b062351afe52dc7dfe982ddaa2026c5d Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Thu, 11 Jul 2013 18:05:02 +0200 Subject: [PATCH] Fix deadlock in kthread_cond_wait. --- sortix/kthread.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sortix/kthread.cpp b/sortix/kthread.cpp index 1a478aeb..639ce164 100644 --- a/sortix/kthread.cpp +++ b/sortix/kthread.cpp @@ -60,7 +60,8 @@ extern "C" void kthread_cond_wait(kthread_cond_t* cond, kthread_mutex_t* mutex) elem.next = NULL; elem.woken = 0; if ( cond->last ) { cond->last->next = &elem; } - if ( !cond->last ) { cond->last = cond->first = &elem; } + if ( !cond->last ) { cond->first = &elem; } + cond->last = &elem; while ( !elem.woken ) { kthread_mutex_unlock(mutex); @@ -78,7 +79,8 @@ extern "C" unsigned long kthread_cond_wait_signal(kthread_cond_t* cond, elem.next = NULL; elem.woken = 0; if ( cond->last ) { cond->last->next = &elem; } - if ( !cond->last ) { cond->last = cond->first = &elem; } + if ( !cond->last ) { cond->first = &elem; } + cond->last = &elem; while ( !elem.woken ) { if ( Signal::IsPending() )