mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 01:15:46 +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;
|
PLT_THREAD *current_thread;
|
||||||
|
|
||||||
PltLockMutex(&thread_list_lock);
|
PltLockMutex(&thread_list_lock);
|
||||||
current_thread = thread_head;
|
|
||||||
while (current_thread != NULL) {
|
if (thread_head == thread)
|
||||||
if (current_thread->next == thread) {
|
{
|
||||||
break;
|
// 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);
|
PltUnlockMutex(&thread_list_lock);
|
||||||
|
|
||||||
CloseHandle(thread->termevent);
|
CloseHandle(thread->termevent);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user