kernel: Do not attempt to interrupt a thread that is not waiting

This commit is contained in:
Pawel Dziepak 2013-12-31 03:50:01 +01:00
parent 2d52abbd5d
commit 135bb9c959
1 changed files with 6 additions and 4 deletions

View File

@ -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;