updates.
[runtime.git] / lib / silcutil / win32 / silcwin32schedule.c
index e4a02a54c0e39cce405c4632eeab9fa5d9bd475a..a6539c747d0b0c8d034d5de7b72b760d89e8766e 100644 (file)
@@ -84,15 +84,17 @@ int silc_select(int n, fd_set *readfds, fd_set *writefds,
     curtime = GetTickCount();
     while (timer) {
       WaitMessage();
-      KillTimer(NULL, timer);
 
       while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
-       if (msg.message == WM_TIMER)
+       if (msg.message == WM_TIMER) {
+         KillTimer(NULL, timer);
          return 0;
+       }
        TranslateMessage(&msg); 
        DispatchMessage(&msg); 
       }
 
+      KillTimer(NULL, timer);
       if (timeo != INFINITE) {
        timeo -= GetTickCount() - curtime;
        if (timeo < 0)