Fix removal of the last thread from the thread list

This commit is contained in:
Cameron Gutman 2014-08-23 00:11:03 -07:00
parent 63c8fd2d6b
commit 129951975f

View File

@ -97,6 +97,15 @@ void PltCloseThread(PLT_THREAD *thread) {
PLT_THREAD *current_thread;
PltLockMutex(&thread_list_lock);
if (thread_head == thread)
{
// Remove the thread from the head
thread_head = thread_head->next;
}
else
{
// Find the thread in the list
current_thread = thread_head;
while (current_thread != NULL) {
if (current_thread->next == thread) {
@ -110,6 +119,8 @@ void PltCloseThread(PLT_THREAD *thread) {
// Unlink this thread
current_thread->next = thread->next;
}
PltUnlockMutex(&thread_list_lock);
CloseHandle(thread->termevent);