+ do
+ r = ioctl (pfd[i].fd, FIONREAD, &avail);
+ while (r == -1 && (errno == EAGAIN || errno == EINTR));
+ if (avail < 0)
+ avail = 0;
When ioctl returns -1, maybe because FIONREAD is not supported or so,
this loops endlessly.
How so? Only for EAGAIN and EINTR. If FIONREAD is supported, it will
return EINVAL or something like that.
+ errno = 0;
What's the purpose of that? If recv() needs errro to be 0 upon entry,
this statement should come before the recv() call. It cannot be needed
for the caller, since at this point it is guaranteed that the function
returns with "return rc;" which is positive.
The idea is that we return POLLHUP or POLLERR, so having poll set an
errno is misleading. If a function is allowed to modify errno
arbitrarily (as long as it returns a positive value) I'm ok with
removing this line.
Ok to remove the errno = 0, and to leave as is the part you commented above?
Paolo