From 135bb9c9596ff16f1d775ca48f6ae884af7dc52b Mon Sep 17 00:00:00 2001 From: Pawel Dziepak Date: Tue, 31 Dec 2013 03:50:01 +0100 Subject: [PATCH] kernel: Do not attempt to interrupt a thread that is not waiting --- headers/private/kernel/thread.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/headers/private/kernel/thread.h b/headers/private/kernel/thread.h index 96d80ba912..f41987c8c4 100644 --- a/headers/private/kernel/thread.h +++ b/headers/private/kernel/thread.h @@ -383,10 +383,12 @@ thread_unblock_locked(Thread* thread, status_t status) static inline status_t thread_interrupt(Thread* thread, bool kill) { - if ((thread->wait.flags & B_CAN_INTERRUPT) != 0 - || (kill && (thread->wait.flags & B_KILL_CAN_INTERRUPT) != 0)) { - thread_unblock_locked(thread, B_INTERRUPTED); - return B_OK; + if (thread_is_blocked(thread)) { + if ((thread->wait.flags & B_CAN_INTERRUPT) != 0 + || (kill && (thread->wait.flags & B_KILL_CAN_INTERRUPT) != 0)) { + thread_unblock_locked(thread, B_INTERRUPTED); + return B_OK; + } } return B_NOT_ALLOWED;