diff --git a/src/system/kernel/thread.cpp b/src/system/kernel/thread.cpp index 4ca900f772..8f3450354b 100644 --- a/src/system/kernel/thread.cpp +++ b/src/system/kernel/thread.cpp @@ -2286,7 +2286,10 @@ user_unblock_thread(thread_id threadID, status_t status) if (thread->user_thread == NULL) return B_NOT_ALLOWED; - thread_unblock_locked(thread, status); + if (thread->user_thread->wait_status > 0) { + thread->user_thread->wait_status = status; + thread_unblock_locked(thread, status); + } return B_OK; } diff --git a/src/system/libroot/posix/pthread/pthread_rwlock.cpp b/src/system/libroot/posix/pthread/pthread_rwlock.cpp index 7868fa546c..65e83bed37 100644 --- a/src/system/libroot/posix/pthread/pthread_rwlock.cpp +++ b/src/system/libroot/posix/pthread/pthread_rwlock.cpp @@ -225,10 +225,8 @@ private: waiters.Remove(waiter); owner = waiter->thread; - if (waiter->userThread->wait_status > 0) { - waiter->userThread->wait_status = B_OK; + if (waiter->userThread->wait_status > 0) _kern_unblock_thread(waiter->thread, B_OK); - } } return; } @@ -248,7 +246,6 @@ private: waiters.Remove(waiter); if (waiter->userThread->wait_status > 0) { - waiter->userThread->wait_status = B_OK; readers[readerCount++] = waiter->thread; reader_count++; }