diff options
author | George Hazan <george.hazan@gmail.com> | 2016-08-25 09:36:43 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-08-25 09:36:43 +0000 |
commit | 8894ea48fd4f124c2c93ddca57c95871b3e81258 (patch) | |
tree | dc3401deee38ca09c4e7b2b70f63a992794fbf20 | |
parent | 4441cebd24986683d7997edb3a9a65021fcf6428 (diff) |
fix for a major handle leak introduced in rev #15740
git-svn-id: http://svn.miranda-ng.org/main/trunk@17206 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | src/mir_core/src/threads.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/mir_core/src/threads.cpp b/src/mir_core/src/threads.cpp index 91d4c281b7..f4e247e65c 100644 --- a/src/mir_core/src/threads.cpp +++ b/src/mir_core/src/threads.cpp @@ -96,7 +96,7 @@ static LIST<THREAD_WAIT_ENTRY> threads(10, NumericKeySortT); struct FORK_ARG
{
- HANDLE hEvent;
+ HANDLE hEvent, hThread;
union
{
pThreadFunc threadcode;
@@ -113,15 +113,14 @@ DWORD WINAPI forkthread_r(void *arg) FORK_ARG *fa = (FORK_ARG*)arg;
pThreadFunc callercode = fa->threadcode;
void *cookie = fa->arg;
+ CloseHandle(fa->hThread);
Thread_Push((HINSTANCE)callercode);
SetEvent(fa->hEvent);
callercode(cookie);
- HANDLE hThread = GetCurrentThread();
- SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL);
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
Thread_Pop();
- CloseHandle(hThread);
return 0;
}
@@ -133,12 +132,12 @@ MIR_CORE_DLL(HANDLE) mir_forkthread(void(__cdecl *threadcode)(void*), void *arg) fa.arg = arg;
DWORD threadID;
- HANDLE hThread = CreateThread(NULL, 0, forkthread_r, &fa, 0, &threadID);
- if (hThread != NULL)
+ fa.hThread = CreateThread(NULL, 0, forkthread_r, &fa, 0, &threadID);
+ if (fa.hThread != NULL)
WaitForSingleObject(fa.hEvent, INFINITE);
CloseHandle(fa.hEvent);
- return hThread;
+ return fa.hThread;
}
/////////////////////////////////////////////////////////////////////////////////////////
|