diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2019-12-27 10:11:01 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2019-12-27 13:41:29 +0100 |
commit | 388c582ee9a54a5b358e5aad21407ee339fcf1ef (patch) | |
tree | 3292d4cc81f83b6be45d83a32561baf06b48389d /main/network.c | |
parent | 7b69855bd0aa235ab72ce2bf8e9221cbe1053902 (diff) | |
download | php-git-388c582ee9a54a5b358e5aad21407ee339fcf1ef.tar.gz |
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.
Diffstat (limited to 'main/network.c')
-rw-r--r-- | main/network.c | 4 |
1 files changed, 3 insertions, 1 deletions
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); |