From 1cd9caa88edf51adaec317fe13b6853ec8d304f0 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Tue, 14 Jan 2003 11:47:24 +0000 Subject: [PATCH] Reverted, bad commit --- lib/silcutil/win32/silcwin32schedule.c | 28 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) 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: -- 2.43.0