From a6eff65259f6e1b7554bc88079019ad0fdac461b Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 16 Jul 2014 12:08:34 +0200 Subject: [PATCH] Fixed ExitThread, now running pthread_exit and setting event. --- winpr/include/winpr/thread.h | 2 +- winpr/libwinpr/thread/thread.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/winpr/include/winpr/thread.h b/winpr/include/winpr/thread.h index 83a398c..54e9e19 100644 --- a/winpr/include/winpr/thread.h +++ b/winpr/include/winpr/thread.h @@ -163,7 +163,7 @@ WINPR_API HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T d WINPR_API HANDLE CreateRemoteThread(HANDLE hProcess, LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId); -WINPR_API VOID ExitThread(DWORD dwExitCode); +WINPR_API DECLSPEC_NORETURN VOID ExitThread(DWORD dwExitCode); WINPR_API BOOL GetExitCodeThread(HANDLE hThread, LPDWORD lpExitCode); WINPR_API HANDLE _GetCurrentThread(void); diff --git a/winpr/libwinpr/thread/thread.c b/winpr/libwinpr/thread/thread.c index e3ed524..5c287dc 100644 --- a/winpr/libwinpr/thread/thread.c +++ b/winpr/libwinpr/thread/thread.c @@ -425,6 +425,12 @@ VOID ExitThread(DWORD dwExitCode) backtrace(thread->exit_stack, 20); #endif ListDictionary_Unlock(thread_list); + set_event(thread); + + if (thread->detached || !thread->started) + cleanup_handle(thread); + + pthread_exit(thread->dwExitCode); } } @@ -537,7 +543,7 @@ VOID DumpThreadHandles(void) #if defined(HAVE_EXECINFO_H) backtrace(stack, 20); #endif - fprintf(stderr, "---------------- %s ----------------------\n", __FUNCTION); + fprintf(stderr, "---------------- %s ----------------------\n", __FUNCTION); fprintf(stderr, "---------------- Called from ----------------------------\n"); #if defined(HAVE_EXECINFO_H) backtrace_symbols_fd(stack, 20, STDERR_FILENO); -- 2.7.4