]> granicus.if.org Git - php/commitdiff
Make new poll stuff work on win32 (and still be safe on unix)
authorWez Furlong <wez@php.net>
Fri, 17 Sep 2004 14:36:55 +0000 (14:36 +0000)
committerWez Furlong <wez@php.net>
Fri, 17 Sep 2004 14:36:55 +0000 (14:36 +0000)
main/network.c
main/streams/xp_socket.c
win32/build/config.w32

index 86d71cd14db1372083b08c700ae03fb1d6bc2ca5..d16f796832a6ec29eba64aab045156eb74b04b66 100644 (file)
@@ -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;
 }
 
index 746a9348c4fbe7ea895100de96e93dd8a76141bb..f67161698c788798969d20092408e06784c9e98d 100644 (file)
@@ -127,6 +127,9 @@ static void php_sock_stream_wait_for_data(php_stream *stream, php_netstream_data
 
                if (retval >= 0)
                        break;
+
+               if (php_socket_errno() != EINTR)
+                       break;
        }
 }
 
index 1bb0d0e9e6e591a0c5f05488d93e03f41e8a8434..38cd72de9693a0f88a2770c045bef98fafafce6d 100644 (file)
@@ -218,7 +218,7 @@ AC_DEFINE('HAVE_IPV6', main_network_has_ipv6);
 /* this allows up to 256 sockets to be select()ed in a single
  * call to select(), instead of the usual 64 */
 ARG_ENABLE('fd-setsize', "Set maximum number of sockets for select(2)", "256");
-AC_DEFINE('FD_SETSIZE', PHP_FD_SETSIZE);
+ADD_FLAG("CFLAGS", "/D FD_SETSIZE=" + parseInt(PHP_FD_SETSIZE));
 
 ARG_ENABLE("memory-limit", "Enable memory limit checking code", "no");