From: Christoph M. Becker Date: Fri, 27 Dec 2019 09:11:01 +0000 (+0100) Subject: Clarify usage of max_fd in php_poll2() on Windows X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=388c582ee9a54a5b358e5aad21407ee339fcf1ef;p=php Clarify usage of max_fd in php_poll2() on Windows 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. --- diff --git a/main/network.c b/main/network.c index 5f1957e0fd..ece2b372ea 100644 --- a/main/network.c +++ b/main/network.c @@ -1171,16 +1171,18 @@ PHPAPI void _php_emit_fd_setsize_warning(int max_fd) 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);