From 90ce69b0f19ab410d502fa93a64f02de55cf4a53 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 19 Sep 2014 14:19:55 +0200 Subject: score: Critical fix for _Thread_queue_Dequeue() Do not return NULL in case we can dequeue the executing thread. This bug was introduced with 32506647001a815e3c0daf25757d386104a07184. --- cpukit/score/src/threadqdequeue.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cpukit/score/src/threadqdequeue.c b/cpukit/score/src/threadqdequeue.c index e364aa91e8..52ba009021 100644 --- a/cpukit/score/src/threadqdequeue.c +++ b/cpukit/score/src/threadqdequeue.c @@ -54,18 +54,20 @@ Thread_Control *_Thread_queue_Dequeue( } } - /* - * We did not find a thread to unblock. - */ - if ( !the_thread ) { + if ( the_thread == NULL ) { + /* + * We did not find a thread to unblock in the queue. Maybe the executing + * thread is about to block on this thread queue. + */ sync_state = the_thread_queue->sync_state; if ( (sync_state == THREAD_BLOCKING_OPERATION_TIMEOUT) || (sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) ) { the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SATISFIED; the_thread = _Thread_Executing; + } else { + _ISR_Enable( level ); + return NULL; } - _ISR_Enable( level ); - return NULL; } /* -- cgit v1.2.3