On Thu, May 11, 2017 at 01:02:14PM +0100, Daniel P. Berrange wrote: > The previous commit: > > commit 17f1e64f00011fb745019119e21b26e4aba65e4b > Author: Paul Eggert <[email protected]> > 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 <[email protected]> > --- > 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
I've just noticed that Bruno pushed a similar patch to git master yesterday: commit 4df5fde5d4f69397f3435c9804da5c88ddc7721e Author: Bruno Haible <[email protected]> Date: Thu May 11 00:38:03 2017 +0200 poll: Fix link error on native Windows. * lib/poll.c [WINDOWS_NATIVE]: Undefine recv. unfortunately while that patch may have fixed a linker error, it does not actually make poll() function correctly. We're still passing HANDLE objects to the rpl_select() method, instead of calling the native select() method. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
