Skip to content

Commit d8315a7

Browse files
committed
Merge pull request #1003 from shoelzer/master
poll: Use GetTickCount64 to avoid wraparound issues
2 parents 2d0f7f1 + 8fe3784 commit d8315a7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

compat/poll/poll.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,8 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
446446
static HANDLE hEvent;
447447
WSANETWORKEVENTS ev;
448448
HANDLE h, handle_array[FD_SETSIZE + 2];
449-
DWORD ret, wait_timeout, nhandles, start = 0, elapsed, orig_timeout = 0;
449+
DWORD ret, wait_timeout, nhandles, elapsed, orig_timeout = 0;
450+
ULONGLONG start = 0;
450451
fd_set rfds, wfds, xfds;
451452
BOOL poll_again;
452453
MSG msg;
@@ -462,7 +463,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
462463
if (timeout != INFTIM)
463464
{
464465
orig_timeout = timeout;
465-
start = GetTickCount();
466+
start = GetTickCount64();
466467
}
467468

468469
if (!hEvent)
@@ -611,7 +612,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
611612

612613
if (!rc && orig_timeout && timeout != INFTIM)
613614
{
614-
elapsed = GetTickCount() - start;
615+
elapsed = (DWORD)(GetTickCount64() - start);
615616
timeout = elapsed >= orig_timeout ? 0 : orig_timeout - elapsed;
616617
}
617618

0 commit comments

Comments
 (0)