Merge pull request #2801 from bmiklautz/fix/thread

winpr/thread: small cleanups
This commit is contained in:
Marc-André Moreau 2015-07-28 08:47:06 -04:00
commit 611c194f80
1 changed files with 32 additions and 29 deletions

View File

@ -281,17 +281,15 @@ static void* thread_launcher(void* arg)
DWORD res = -1;
void* rc = NULL;
WINPR_THREAD* thread = (WINPR_THREAD*) arg;
void *(*fkt)(void*);
if (!thread)
{
WLog_ERR(TAG, "Called with invalid argument %p", arg);
goto exit;
}
else
{
void *(*fkt)(void*) = (void*) thread->lpStartAddress;
if (!fkt)
if (!(fkt = (void*) thread->lpStartAddress))
{
WLog_ERR(TAG, "Thread function argument is %p", fkt);
goto exit;
@ -315,7 +313,6 @@ static void* thread_launcher(void* arg)
assert(ListDictionary_Contains(thread_list, &thread->thread));
rc = fkt(thread->lpParameter);
}
exit:
@ -330,7 +327,6 @@ exit:
if (thread->detached || !thread->started)
cleanup_handle(thread);
}
pthread_exit((void*) (size_t) res);
return rc;
}
@ -685,7 +681,13 @@ DWORD ResumeThread(HANDLE hThread)
return (DWORD)-1;
if (!thread->started)
winpr_StartThread(thread);
{
if (!winpr_StartThread(thread))
{
pthread_mutex_unlock(&thread->mutex);
return (DWORD)-1;
}
}
else
WLog_WARN(TAG, "Thread already started!");
@ -703,6 +705,7 @@ DWORD SuspendThread(HANDLE hThread)
BOOL SwitchToThread(VOID)
{
WLog_ERR(TAG, "Function not implemented!");
return TRUE;
}