Commit b424612cce074e5f71fa8b33509fb1f1b52f69a2

Con Kolivas 2013-10-27T13:35:47

Use a sanity check on timeout on windows.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/util.c b/util.c
index 363c73c..032a82c 100644
--- a/util.c
+++ b/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);