bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] poll: fix regression in Win32 emulation of poll function


From: Daniel P. Berrange
Subject: [PATCH] poll: fix regression in Win32 emulation of poll function
Date: Thu, 11 May 2017 13:02:14 +0100

The previous commit:

  commit 17f1e64f00011fb745019119e21b26e4aba65e4b
  Author: Paul Eggert <address@hidden>
  Date:   Tue Feb 24 16:16:19 2015 -0800

    poll: port to MSVC v18 on MS-Windows 8.1

    Problem reported by Gisle Vanem in:
    http://lists.gnu.org/archive/html/bug-gnulib/2015-02/msg00139.html
    * lib/poll.c: Always include <sys/select.h> and <sys/socket.h>.
    * modules/poll (Depends-on) [!HAVE_POLL || REPLACE_POLL]:
    Add sys_socket.

attempted to fix a compilation bug, but in doing so it significantly
changed the semantics of the code. Instead of the poll() wrapper
calling the WINSOCK native select() & recv() functions, it would
now call the GNULIB wrapped versions. This is a mistake because
the former take SOCKET handles, while the latter take FDs. As a
result, while the poll() code compiled, it didn't actually work
when used.

Rather than reverting the above commit, which would reintroduce
the compile error reporting, we simply undefine the wrappers
so the code calls the WINSOCK native functions once again.

Signed-off-by: Daniel P. Berrange <address@hidden>
---
 lib/poll.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/poll.c b/lib/poll.c
index c4b2127..a26838c 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -54,6 +54,16 @@
 #include <sys/select.h>
 #include <sys/socket.h>
 
+#ifdef WINDOWS_NATIVE
+/* The Win32 emulation assumes we're using the Winsock native
+ * functions that accept SOCKETs, not the GNULIB wrapped versions
+ * that accept  FDs. The sys/select.h & sys/socket.h header pull
+ * in the wrapped versions, so we must unset them.
+ */
+# undef recv
+# undef select
+#endif
+
 #ifdef HAVE_SYS_IOCTL_H
 # include <sys/ioctl.h>
 #endif
-- 
2.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]