Message177109
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. |
|
Date |
User |
Action |
Args |
2012-12-07 18:50:51 | sbt | set | recipients:
+ sbt, jcea, pitrou, giampaolo.rodola, trent |
2012-12-07 18:50:51 | sbt | set | messageid: <1354906251.02.0.112484253474.issue16507@psf.upfronthosting.co.za> |
2012-12-07 18:50:50 | sbt | link | issue16507 messages |
2012-12-07 18:50:50 | sbt | create | |
|