Actually, `max_fd` is not used on Windows, since `PHP_SAFE_MAX_FD` and
`select` ignore it; so it makes no sense to calculate it in the loop.
Even worse, since `php_socket_t` is unsigned on Windows, it will never
be modified during the loop, because `SOCK_ERR` is already the largest
representable value of that type.
Therefore we skip the loop on Windows, and add a clarifying comment.
PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout)
{
fd_set rset, wset, eset;
- php_socket_t max_fd = SOCK_ERR;
+ php_socket_t max_fd = SOCK_ERR; /* effectively unused on Windows */
unsigned int i;
int n;
struct timeval tv;
+#ifndef PHP_WIN32
/* check the highest numbered descriptor */
for (i = 0; i < nfds; i++) {
if (ufds[i].fd > max_fd)
max_fd = ufds[i].fd;
}
+#endif
PHP_SAFE_MAX_FD(max_fd, nfds + 1);