php/php-5.4.11-select.patch

52 lines
1.8 KiB
Diff
Raw Normal View History

diff -up php-5.4.11/sapi/cli/php_cli_server.c.select php-5.4.11/sapi/cli/php_cli_server.c
--- php-5.4.11/sapi/cli/php_cli_server.c.select 2013-01-16 02:10:30.000000000 -0500
+++ php-5.4.11/sapi/cli/php_cli_server.c 2013-02-01 12:12:04.650950760 -0500
@@ -710,10 +710,9 @@ static void php_cli_server_poller_remove
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
}
#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;