From 8d329ba6840fd40ef89c5515a76ad28ff364ba75 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 16 Nov 2015 10:54:05 +0000 Subject: simple thread's handle gets closed too early git-svn-id: http://svn.miranda-ng.org/main/trunk@15740 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_core/src/threads.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mir_core/src/threads.cpp b/src/mir_core/src/threads.cpp index 8f73d5bb4d..600d245ea5 100644 --- a/src/mir_core/src/threads.cpp +++ b/src/mir_core/src/threads.cpp @@ -118,8 +118,10 @@ DWORD WINAPI forkthread_r(void *arg) callercode(cookie); - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); + HANDLE hThread = GetCurrentThread(); + SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); Thread_Pop(); + CloseHandle(hThread); return 0; } @@ -132,10 +134,8 @@ MIR_CORE_DLL(HANDLE) mir_forkthread(void(__cdecl *threadcode)(void*), void *arg) DWORD threadID; HANDLE hThread = CreateThread(NULL, 0, forkthread_r, &fa, 0, &threadID); - if (hThread != NULL) { + if (hThread != NULL) WaitForSingleObject(fa.hEvent, INFINITE); - CloseHandle(hThread); - } CloseHandle(fa.hEvent); return hThread; -- cgit v1.2.3