Merge branch 'et/win32-poll-timeout'
* et/win32-poll-timeout: poll: honor the timeout on Win32
This commit is contained in:
		| @ -446,7 +446,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout) | |||||||
|   static HANDLE hEvent; |   static HANDLE hEvent; | ||||||
|   WSANETWORKEVENTS ev; |   WSANETWORKEVENTS ev; | ||||||
|   HANDLE h, handle_array[FD_SETSIZE + 2]; |   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; |   fd_set rfds, wfds, xfds; | ||||||
|   BOOL poll_again; |   BOOL poll_again; | ||||||
|   MSG msg; |   MSG msg; | ||||||
| @ -459,6 +459,12 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout) | |||||||
|       return -1; |       return -1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |   if (timeout != INFTIM) | ||||||
|  |     { | ||||||
|  |       orig_timeout = timeout; | ||||||
|  |       start = GetTickCount(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|   if (!hEvent) |   if (!hEvent) | ||||||
|     hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); |     hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); | ||||||
|  |  | ||||||
| @ -603,7 +609,13 @@ restart: | |||||||
| 	rc++; | 	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); |       SleepEx (1, TRUE); | ||||||
|       goto restart; |       goto restart; | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Junio C Hamano
					Junio C Hamano