Browse Source

Use a sanity check on timeout on windows.

Con Kolivas 12 years ago
parent
commit
b424612cce
1 changed files with 5 additions and 1 deletions
  1. 5 1
      util.c

+ 5 - 1
util.c

@@ -1061,9 +1061,13 @@ void cgtimer_time(cgtimer_t *ts_start)
 
 static void liSleep(LARGE_INTEGER *li, int timeout)
 {
-	HANDLE hTimer = CreateWaitableTimer(NULL, TRUE, NULL);
+	HANDLE hTimer;
 	DWORD ret;
 
+	if (unlikely(timeout <= 0))
+		return;
+
+	hTimer = CreateWaitableTimer(NULL, TRUE, NULL);
 	if (unlikely(!hTimer))
 		quit(1, "Failed to create hTimer in liSleep");
 	ret = SetWaitableTimer(hTimer, li, 0, NULL, NULL, 0);