Author: fireball
Date: Fri Dec 10 21:17:49 2010
New Revision: 50006

URL: http://svn.reactos.org/svn/reactos?rev=50006&view=rev
Log:
- Return time difference to the next timeout as a 64 bit integer instead of 32 
bit which sometimes could "overlap" in case of big timeouts.
See issue #5758 for more details.

Modified:
    branches/arwinss/reactos/subsystems/win32/win32k/wine/timeout.c

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/timeout.c
URL: 
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/timeout.c?rev=50006&r1=50005&r2=50006&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/timeout.c 
[iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/timeout.c 
[iso-8859-1] Fri Dec 10 21:17:49 2010
@@ -113,7 +113,7 @@
 }
 
 /* process pending timeouts and return the time until the next timeout, in 
milliseconds */
-static int get_next_timeout(void)
+static void get_next_timeout(LARGE_INTEGER *result)
 {
     timeout_t current_time;
     get_current_time(&current_time);
@@ -150,27 +150,32 @@
         if ((ptr = list_head( &timeout_list )) != NULL)
         {
             struct timeout_user *timeout = LIST_ENTRY( ptr, struct 
timeout_user, entry );
-            //int diff = (timeout->when - current_time + 9999) / 10000;
-            int diff = timeout->when - current_time + 1;
-            if (diff < 0) diff = 0;
-            return diff;
-        }
-    }
-    return -1;  /* no pending timeouts */
+            LARGE_INTEGER diff;
+            diff.QuadPart = timeout->when - current_time;
+            //DPRINT1("diff %d, when %I64d, current %I64d\n", diff, 
timeout->when, current_time);
+            if (diff.QuadPart < 0) diff.QuadPart = 0;
+
+            result->QuadPart = diff.QuadPart;
+            return;
+        }
+    }
+
+    result->QuadPart = -1LL;
+    return;  /* no pending timeouts */
 }
 
 VOID
 ProcessTimers()
 {
-    int timeout;
+    LARGE_INTEGER timeout;
     LARGE_INTEGER DueTime;
 
-    timeout = get_next_timeout();
-
-    if (timeout != -1)
+    get_next_timeout(&timeout);
+    DPRINT("ProcessTimers() timeout %I64d\n", timeout.QuadPart);
+    if (timeout.QuadPart != -1LL)
     {
         /* Wait for the next time out */
-        DueTime.QuadPart = -timeout;
+        DueTime.QuadPart = -timeout.QuadPart;
         KeSetTimer(MasterTimer, DueTime, NULL);
     }
     else


Reply via email to