From 2a15b3a3713d7773a8a46d491f7c649d701000ee Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Sat, 9 Sep 2017 19:37:52 +0200 Subject: [PATCH] epoll: fix logic error in epoll_wait() timeout recomputation --- src/epoll.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/epoll.c b/src/epoll.c index aae7898..f9d8fce 100644 --- a/src/epoll.c +++ b/src/epoll.c @@ -196,9 +196,10 @@ int epoll_wait(epoll_t port_handle, /* Events were dequeued, but none were relevant. Recompute timeout. */ if (timeout > 0) { - gqcs_timeout = due - GetTickCount64(); + ULONGLONG now = GetTickCount64(); + gqcs_timeout = (now < due) ? (DWORD)(due - now) : 0; } - } while (timeout > 0); + } while (gqcs_timeout > 0); return 0; }