]> granicus.if.org Git - php/commitdiff
Fixed bug #64128 buit-in web server is broken on ppc64.
authorRemi Collet <remi@php.net>
Fri, 1 Feb 2013 18:23:25 +0000 (19:23 +0100)
committerRemi Collet <remi@php.net>
Fri, 1 Feb 2013 18:23:25 +0000 (19:23 +0100)
fdset management using bit operator is broken on non-x86 arch
and cause built-in server the enter an infinite loop of "select"
and never handle any request.

NEWS
sapi/cli/php_cli_server.c

diff --git a/NEWS b/NEWS
index 2fc746e3fe295d1ccc1e950eae9ee7dcb3b02188..2aff180fa9b7cb6cf27a8a3fa6f02154cd0048e3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2012, PHP 5.4.13
 
+- CLI server:
+  . Fixed bug #64128 (buit-in web server is broken on ppc64). (Remi)
+
 ?? ??? 2012, PHP 5.4.12
 
 - Core:
index 28aba198f546896b9c99fb3cc28f9fe9dcbaac43..6a4e7c53ab7c96edc20d6b7b0d6366f934fd5877 100644 (file)
@@ -710,10 +710,9 @@ static void php_cli_server_poller_remove(php_cli_server_poller *poller, int mode
        if (fd == poller->max_fd) {
                while (fd > 0) {
                        fd--;
-                       if (((unsigned int *)&poller->rfds)[fd / (8 * sizeof(unsigned int))] || ((unsigned int *)&poller->wfds)[fd / (8 * sizeof(unsigned int))]) {
+                       if (PHP_SAFE_FD_ISSET(fd, &poller->rfds) || PHP_SAFE_FD_ISSET(fd, &poller->wfds)) {
                                break;
                        }
-                       fd -= fd % (8 * sizeof(unsigned int));
                }
                poller->max_fd = fd;
        }
@@ -772,23 +771,20 @@ static int php_cli_server_poller_iter_on_active(php_cli_server_poller *poller, v
        }
 
 #else
-       php_socket_t fd = 0;
+       php_socket_t fd;
        const php_socket_t max_fd = poller->max_fd;
-       const unsigned int *pr = (unsigned int *)&poller->active.rfds,
-                          *pw = (unsigned int *)&poller->active.wfds,
-                          *e = pr + (max_fd + (8 * sizeof(unsigned int)) - 1) / (8 * sizeof(unsigned int));
-       unsigned int mask;
-       while (pr < e && fd <= max_fd) {
-               for (mask = 1; mask; mask <<= 1, fd++) {
-                       int events = (*pr & mask ? POLLIN: 0) | (*pw & mask ? POLLOUT: 0);
-                       if (events) {
-                               if (SUCCESS != callback(opaque, fd, events)) {
-                                       retval = FAILURE;
-                               }
-                       }
+
+       for (fd=0 ; fd<=max_fd ; fd++)  {
+               if (PHP_SAFE_FD_ISSET(fd, &poller->active.rfds)) {
+                if (SUCCESS != callback(opaque, fd, POLLIN)) {
+                    retval = FAILURE;
+                }
+               }
+               if (PHP_SAFE_FD_ISSET(fd, &poller->active.wfds)) {
+                if (SUCCESS != callback(opaque, fd, POLLOUT)) {
+                    retval = FAILURE;
+                }
                }
-               pr++;
-               pw++;
        }
 #endif
        return retval;