Don't panic in case a thread is not in the wait queue of a sem anymore. On SMP

systems it can easily happen that the thread gets removed from the queue (when
it times out for example) during the time we don't hold the sem lock.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23749 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2008-01-26 18:44:23 +00:00
parent 1b0e74fc18
commit 36b55f4694
+9 -6
View File
@@ -601,18 +601,21 @@ sem_interrupt_thread(struct thread *thread)
}
clear_thread_queue(&wakeupQueue);
if (remove_thread_from_sem(thread, &sSems[slot], &wakeupQueue,
B_INTERRUPTED, true) != B_OK) {
panic("sem_interrupt_thread: thread %ld not found in sem %ld's wait "
"queue\n", thread->id, thread->sem.blocking);
}
status_t result = remove_thread_from_sem(thread, &sSems[slot],
&wakeupQueue, B_INTERRUPTED, true);
RELEASE_SEM_LOCK(sSems[slot]);
if (result != B_OK) {
// The thread is not in the wait queue anymore. Probably it just timed
// out before we locked the sem.
return result;
}
while ((thread = thread_dequeue(&wakeupQueue)) != NULL)
scheduler_enqueue_in_run_queue(thread);
return B_NO_ERROR;
return B_OK;
}