summaryrefslogtreecommitdiff
path: root/main/network.c
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2004-09-17 14:36:55 +0000
committerWez Furlong <wez@php.net>2004-09-17 14:36:55 +0000
commitff4e970fb1c71c4998911c6185bfbfe92d4c9001 (patch)
tree539da1a7f4e0454df35da22f6b0237a8832b1be7 /main/network.c
parent99e290f882c9116e74418b9271a75d557533c4f5 (diff)
downloadphp-git-ff4e970fb1c71c4998911c6185bfbfe92d4c9001.tar.gz
Make new poll stuff work on win32 (and still be safe on unix)
Diffstat (limited to 'main/network.c')
-rw-r--r--main/network.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/main/network.c b/main/network.c
index 86d71cd14d..d16f796832 100644
--- a/main/network.c
+++ b/main/network.c
@@ -1047,7 +1047,7 @@ PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout)
php_socket_t max_fd = SOCK_ERR;
unsigned int i, n;
struct timeval tv;
-
+
/* check the highest numbered descriptor */
for (i = 0; i < nfds; i++) {
if (ufds[i].fd > max_fd)
@@ -1061,19 +1061,14 @@ PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout)
FD_ZERO(&eset);
for (i = 0; i < nfds; i++) {
- if (ufds[i].fd >= FD_SETSIZE) {
- /* unsafe to set */
- ufds[i].revents = POLLNVAL;
- continue;
- }
if (ufds[i].events & PHP_POLLREADABLE) {
- FD_SET(ufds[i].fd, &rset);
+ PHP_SAFE_FD_SET(ufds[i].fd, &rset);
}
if (ufds[i].events & POLLOUT) {
- FD_SET(ufds[i].fd, &wset);
+ PHP_SAFE_FD_SET(ufds[i].fd, &wset);
}
if (ufds[i].events & POLLPRI) {
- FD_SET(ufds[i].fd, &eset);
+ PHP_SAFE_FD_SET(ufds[i].fd, &eset);
}
}
@@ -1081,30 +1076,24 @@ PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout)
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000;
}
-
n = select(max_fd + 1, &rset, &wset, &eset, timeout >= 0 ? &tv : NULL);
if (n >= 0) {
for (i = 0; i < nfds; i++) {
- if (ufds[i].fd >= FD_SETSIZE) {
- continue;
- }
-
ufds[i].revents = 0;
- if (FD_ISSET(ufds[i].fd, &rset)) {
+ if (PHP_SAFE_FD_ISSET(ufds[i].fd, &rset)) {
/* could be POLLERR or POLLHUP but can't tell without probing */
ufds[i].revents |= POLLIN;
}
- if (FD_ISSET(ufds[i].fd, &wset)) {
+ if (PHP_SAFE_FD_ISSET(ufds[i].fd, &wset)) {
ufds[i].revents |= POLLOUT;
}
- if (FD_ISSET(ufds[i].fd, &eset)) {
+ if (PHP_SAFE_FD_ISSET(ufds[i].fd, &eset)) {
ufds[i].revents |= POLLPRI;
}
}
}
-
return n;
}