X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fwin32%2Fsilcwin32thread.c;h=c31e70931381d2f68cecb669bb040f462b102839;hb=40f8443d8d3a6577336ee66d18e04d9ac4d956bb;hp=ca2a211207c9baf3feec507151d2eb5f4d99a63d;hpb=382d15d447b7a95390decfa783836ae4fe255b3d;p=silc.git diff --git a/lib/silcutil/win32/silcwin32thread.c b/lib/silcutil/win32/silcwin32thread.c index ca2a2112..c31e7093 100644 --- a/lib/silcutil/win32/silcwin32thread.c +++ b/lib/silcutil/win32/silcwin32thread.c @@ -4,12 +4,11 @@ Author: Pekka Riikonen - Copyright (C) 2001 Pekka Riikonen + Copyright (C) 2001 - 2005 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,7 +18,7 @@ */ /* $Id$ */ -#include "silcincludes.h" +#include "silc.h" #ifdef SILC_THREADS @@ -28,7 +27,7 @@ typedef struct { HANDLE thread; SilcThreadStart start_func; void *context; - bool waitable; + SilcBool waitable; } *SilcWin32Thread; static DWORD silc_thread_tls; @@ -49,7 +48,7 @@ unsigned __stdcall silc_thread_win32_start(void *context) #endif SilcThread silc_thread_create(SilcThreadStart start_func, void *context, - bool waitable) + SilcBool waitable) { #ifdef SILC_THREADS SilcWin32Thread thread; @@ -61,7 +60,9 @@ SilcThread silc_thread_create(SilcThreadStart start_func, void *context, thread->start_func = start_func; thread->context = context; thread->waitable = waitable; - thread->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)silc_thread_win32_start, (void *)thread, 0, &id); + thread->thread = + CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)silc_thread_win32_start, + (void *)thread, 0, &id); if (!thread->thread) { SILC_LOG_ERROR(("Could not create new thread")); @@ -113,12 +114,12 @@ SilcThread silc_thread_self(void) } return (SilcThread)self; -#else + #else return NULL; #endif } -bool silc_thread_wait(SilcThread thread, void **exit_value) +SilcBool silc_thread_wait(SilcThread thread, void **exit_value) { #ifdef SILC_THREADS SilcWin32Thread self = (SilcWin32Thread)thread; @@ -130,9 +131,7 @@ bool silc_thread_wait(SilcThread thread, void **exit_value) /* The thread is waitable thus we will free all memory after the WaitForSingleObject returns, the thread is destroyed after that. */ - - /* 2 sec timeout, otherwise we would run to infinite loop some cases.. */ - if (WaitForSingleObject(self->thread, 2000) == WAIT_TIMEOUT) + if (WaitForSingleObject(self->thread, 2500) == WAIT_TIMEOUT) TerminateThread(self->thread, 0); silc_free(self);