mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-17 17:05:50 +00:00
Fix removal of the last thread from the thread list
This commit is contained in:
parent
63c8fd2d6b
commit
129951975f
@ -97,19 +97,30 @@ void PltCloseThread(PLT_THREAD *thread) {
|
||||
PLT_THREAD *current_thread;
|
||||
|
||||
PltLockMutex(&thread_list_lock);
|
||||
current_thread = thread_head;
|
||||
while (current_thread != NULL) {
|
||||
if (current_thread->next == thread) {
|
||||
break;
|
||||
|
||||
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) {
|
||||
break;
|
||||
}
|
||||
|
||||
current_thread = current_thread->next;
|
||||
}
|
||||
|
||||
current_thread = current_thread->next;
|
||||
LC_ASSERT(current_thread != NULL);
|
||||
|
||||
// Unlink this thread
|
||||
current_thread->next = thread->next;
|
||||
}
|
||||
|
||||
LC_ASSERT(current_thread != NULL);
|
||||
|
||||
// Unlink this thread
|
||||
current_thread->next = thread->next;
|
||||
PltUnlockMutex(&thread_list_lock);
|
||||
|
||||
CloseHandle(thread->termevent);
|
||||
|
Loading…
x
Reference in New Issue
Block a user