summaryrefslogtreecommitdiff
path: root/sapi/cli/php_cli_server.c
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2013-02-04 14:15:58 +0100
committerAndrey Hristov <andrey@php.net>2013-02-04 14:15:58 +0100
commit643ce95b5bd80e744c7f5e6ac33138f40ed9a1f7 (patch)
tree52244685f5fec1eb87858901cd97f5abf2f8d805 /sapi/cli/php_cli_server.c
parentf45a85c3861325c0ec5f5f5f7af01e4de1545189 (diff)
parent0110662ae9e89d21c119b3287118e82fd435f779 (diff)
downloadphp-git-643ce95b5bd80e744c7f5e6ac33138f40ed9a1f7.tar.gz
Merge branch 'PHP-5.4' of ssh://git.php.net/php-src into PHP-5.4
Diffstat (limited to 'sapi/cli/php_cli_server.c')
-rw-r--r--sapi/cli/php_cli_server.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index 28aba198f5..6a4e7c53ab 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -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;