summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-09-17 12:29:02 -0700
committerJunio C Hamano <gitster@pobox.com>2015-09-17 12:29:02 -0700
commit8d45eefe3ee6bf8499221761df1ee80ead2c8fc0 (patch)
treea24c4fa5f09468873c350dce65ce8d51d9789a8f
parent1c1fee746eb074a80f7dd3c02de286587bac90da (diff)
parentef8b53e78c534d732fe58a46da8dbd922287a56b (diff)
downloadgit-8d45eefe3ee6bf8499221761df1ee80ead2c8fc0.tar.gz
Merge branch 'et/win32-poll-timeout'
* et/win32-poll-timeout: poll: honor the timeout on Win32
-rw-r--r--compat/poll/poll.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/compat/poll/poll.c b/compat/poll/poll.c
index a9b41d89f4..db4e03ed79 100644
--- a/compat/poll/poll.c
+++ b/compat/poll/poll.c
@@ -446,7 +446,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
static HANDLE hEvent;
WSANETWORKEVENTS ev;
HANDLE h, handle_array[FD_SETSIZE + 2];
- DWORD ret, wait_timeout, nhandles;
+ DWORD ret, wait_timeout, nhandles, start = 0, elapsed, orig_timeout = 0;
fd_set rfds, wfds, xfds;
BOOL poll_again;
MSG msg;
@@ -459,6 +459,12 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
return -1;
}
+ if (timeout != INFTIM)
+ {
+ orig_timeout = timeout;
+ start = GetTickCount();
+ }
+
if (!hEvent)
hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
@@ -603,7 +609,13 @@ restart:
rc++;
}
- if (!rc && timeout == INFTIM)
+ if (!rc && orig_timeout && timeout != INFTIM)
+ {
+ elapsed = GetTickCount() - start;
+ timeout = elapsed >= orig_timeout ? 0 : orig_timeout - elapsed;
+ }
+
+ if (!rc && timeout)
{
SleepEx (1, TRUE);
goto restart;