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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user