{"thread":{"id":"15631","subject":"[PATCH] compat/mingw: Support a timeout in the poll emulation if no fds are given","startedAt":"2008-09-23T06:52:16Z","lastAt":"2008-09-23T06:52:16Z","messageCount":1,"participants":["Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"91358","messageId":"48D89220.6080802@viscovery.net","threadId":"15631","inReplyTo":null,"subject":"[PATCH] compat/mingw: Support a timeout in the poll emulation if no fds are given","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-09-23T06:52:16Z","receivedAt":"2008-09-23T06:52:16Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Sixt <johannes.sixt@telecom.at>\n\nOur poll() emulation did not support the timeout argument. With this patch\nwe support it for the simple case where poll() does not need to wait on\nfile descriptors as well because this case amounts to a mere Sleep().\n\nThis is needed if the user sets help.autocorrect is set to a positive\nvalue.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n compat/mingw.c |    7 ++++++-\n 1 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex ccfa2a0..7eed60d 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -263,8 +263,13 @@ int poll(struct pollfd *ufds, unsigned int nfds, int timeout)\n {\n \tint i, pending;\n\n-\tif (timeout != -1)\n+\tif (timeout >= 0) {\n+\t\tif (nfds == 0) {\n+\t\t\tSleep(timeout);\n+\t\t\treturn 0;\n+\t\t}\n \t\treturn errno = EINVAL, error(\"poll timeout not supported\");\n+\t}\n\n \t/* When there is only one fd to wait for, then we pretend that\n \t * input is available and let the actual wait happen when the\n-- \n1.6.0.2.1220.gd1ae.dirty\n"}]}