Richard Oudkerk added the comment:

It seems that the return code of WSAPoll() does not include the count of array 
items with revents == POLLNVAL.  In the case where all of them are POLLNVAL, 
instead of returning 0 (which usually indicates a timeout) it returns -1 and 
WSAGetLastError() == WSAENOTSOCK.

This does not match the MSDN documentation which claims that the return code is 
the number of descriptors for which revents is non-zero.  But it arguably does 
agree with the FreeBSD and MacOSX man pages which say that it returns the 
number of descriptors that are "ready for I/O".


BTW, the implementation of select_poll() assumes that the return code of poll() 
(if non-negative) is equal to the number of non-zero revents fields.  But 
select_have_broken_poll() considers a MacOSX poll() implementation to be good 
even in cases where this assumption is not true:

static int select_have_broken_poll(void)
{
    int poll_test;
    int filedes[2];
    struct pollfd poll_struct = { 0, POLLIN|POLLPRI|POLLOUT, 0 };
    if (pipe(filedes) < 0) {
        return 1;
    }
    poll_struct.fd = filedes[0];
    close(filedes[0]);
    close(filedes[1]);
    poll_test = poll(&poll_struct, 1, 0);
    if (poll_test < 0) {
        return 1;
    } else if (poll_test == 0 && poll_struct.revents != POLLNVAL) {
        return 1;
    }
    return 0;
}

Note that select_have_broken_poll() == FALSE if poll_test == 0 and 
poll_struct.revents == POLLNVAL.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16507>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to