git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] compat/mingw: Support a timeout in the poll emulation if no fds are given
@ 2008-09-23  6:52 Johannes Sixt
  0 siblings, 0 replies; only message in thread
From: Johannes Sixt @ 2008-09-23  6:52 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, msysGit

From: Johannes Sixt <johannes.sixt@telecom.at>

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.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
 compat/mingw.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index ccfa2a0..7eed60d 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -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
-- 
1.6.0.2.1220.gd1ae.dirty

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-09-23  6:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-23  6:52 [PATCH] compat/mingw: Support a timeout in the poll emulation if no fds are given Johannes Sixt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).