From: Pekka Riikonen Date: Tue, 14 Jan 2003 11:47:24 +0000 (+0000) Subject: Reverted, bad commit X-Git-Tag: silc.client.0.9.11.1~13 X-Git-Url: http://git.silc.fi/gitweb/?a=commitdiff_plain;h=1cd9caa88edf51adaec317fe13b6853ec8d304f0;p=silc.git Reverted, bad commit --- diff --git a/lib/silcutil/win32/silcwin32schedule.c b/lib/silcutil/win32/silcwin32schedule.c index 671b1268..22445aef 100644 --- a/lib/silcutil/win32/silcwin32schedule.c +++ b/lib/silcutil/win32/silcwin32schedule.c @@ -52,7 +52,7 @@ int silc_select(SilcScheduleFd fds, SilcUInt32 fds_count, struct timeval *timeout) { - static HANDLE handles[MAXIMUM_WAIT_OBJECTS]; + HANDLE handles[MAXIMUM_WAIT_OBJECTS]; DWORD ready, curtime, timeo; int nhandles = 0, i; MSG msg; @@ -83,17 +83,27 @@ int silc_select(SilcScheduleFd fds, SilcUInt32 fds_count, struct timeval *timeou and wait just for windows messages. */ if (nhandles == 0 && timeout) { UINT timer = SetTimer(NULL, 0, timeo, NULL); + curtime = GetTickCount(); + while (timer) { + WaitMessage(); + + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + if (msg.message == WM_TIMER) { + KillTimer(NULL, timer); + return 0; + } + TranslateMessage(&msg); + DispatchMessage(&msg); + } - GetMessage(&msg, NULL, 0, 0); - if (msg.message == WM_TIMER) { KillTimer(NULL, timer); - return 0; + if (timeo != INFINITE) { + timeo -= GetTickCount() - curtime; + if (timeo < 0) + timeo = 0; + } + timer = SetTimer(NULL, 0, timeo, NULL); } - TranslateMessage(&msg); - DispatchMessage(&msg); - - KillTimer(NULL, timer); - timeo = 0; } retry: