summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-11-16 10:54:05 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-11-16 10:54:05 +0000
commit8d329ba6840fd40ef89c5515a76ad28ff364ba75 (patch)
tree64ef4461fabf0cb359a3b1d98e808d8d2d1c98af /src
parent5fdbf0569c9015e842612e341f075566a2c203f1 (diff)
simple thread's handle gets closed too early
git-svn-id: http://svn.miranda-ng.org/main/trunk@15740 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/mir_core/src/threads.cpp8
1 files 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;