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,6 +97,15 @@ void PltCloseThread(PLT_THREAD *thread) {
|
|||||||
PLT_THREAD *current_thread;
|
PLT_THREAD *current_thread;
|
||||||
|
|
||||||
PltLockMutex(&thread_list_lock);
|
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;
|
current_thread = thread_head;
|
||||||
while (current_thread != NULL) {
|
while (current_thread != NULL) {
|
||||||
if (current_thread->next == thread) {
|
if (current_thread->next == thread) {
|
||||||
@ -110,6 +119,8 @@ void PltCloseThread(PLT_THREAD *thread) {
|
|||||||
|
|
||||||
// Unlink this thread
|
// Unlink this thread
|
||||||
current_thread->next = thread->next;
|
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