[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] poll: fix regression in Win32 emulation of poll function
From: |
Bruno Haible |
Subject: |
Re: [PATCH] poll: fix regression in Win32 emulation of poll function |
Date: |
Thu, 11 May 2017 16:36:46 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-75-generic; KDE/5.18.0; x86_64; ; ) |
Daniel P. Berrange wrote:
> Perhaps I'm mis-understanding, but I was looking at this code:
>
> h = (HANDLE) _get_osfhandle (pfd[i].fd);
> assure (h != NULL);
> if (IsSocketHandle (h))
> {
> int requested = FD_CLOSE;
>
> /* see above; socket handles are mapped onto select. */
> if (sought & (POLLIN | POLLRDNORM))
> {
> requested |= FD_READ | FD_ACCEPT;
> FD_SET ((SOCKET) h, &rfds);
> }
> if (sought & (POLLOUT | POLLWRNORM | POLLWRBAND))
> {
> requested |= FD_WRITE | FD_CONNECT;
> FD_SET ((SOCKET) h, &wfds);
> }
> if (sought & (POLLPRI | POLLRDBAND))
> {
> requested |= FD_OOB;
> FD_SET ((SOCKET) h, &xfds);
> }
>
> which takes the 'FD' and gets the associated SOCKET / HANDLE.
> The 'xfds' fd_set is thus populated with a SOCKET, not a FD.
You're perfectly right. I misread the code. I'm applying this:
2017-05-11 Bruno Haible <address@hidden>
poll: Fix confusion between SOCKETs and FDs on native Windows.
Fix proposed by Daniel P. Berrange <address@hidden>.
* lib/poll.c [WINDOWS_NATIVE]: Undefine select.
diff --git a/lib/poll.c b/lib/poll.c
index c4b2127..818a2cd 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -80,6 +80,10 @@
first argument, not any possible gnulib override. */
# undef recv
+/* Here we need the select() function from Windows, because we pass bit masks
+ of SOCKETs, not bit masks of FDs. */
+# undef select
+
static BOOL IsConsoleHandle (HANDLE h)
{
DWORD mode;