Skip to contentSkip to conversation

compat/mingw: Support a timeout in the poll emulation if no fds are given

PATCH New Johannes Sixt 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 compat/mingw: Support a timeout in the poll emulation if no fds are given

From: Johannes Sixt <[email protected]>

Our poll() emulation did not support the timeout argument. With this patch we support it for the simple case where poll() does not need to wait on file descriptors as well because this case amounts to a mere Sleep().

This is needed if the user sets help.autocorrect is set to a positive value.

---
 compat/mingw.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
compat/mingw.c +6 -1
index ccfa2a0..7eed60d 100644
@@ -263,8 +263,13 @@ int poll(struct pollfd *ufds, unsigned int nfds, int timeout)
 {
 	int i, pending;
 
-	if (timeout != -1)
+	if (timeout >= 0) {
+		if (nfds == 0) {
+			Sleep(timeout);
+			return 0;
+		}
 		return errno = EINVAL, error("poll timeout not supported");
+	}
 
 	/* When there is only one fd to wait for, then we pretend that
 	 * input is available and let the actual wait happen when the
Signature · 1 line
1.6.0.2.1220.gd1ae.dirty