Search
j0ke.net Open Build Service
>
Projects
>
Apache
:
Modules
>
apache2-mod_fastcgi
> mod_fastcgi-2.4.2-poll.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File mod_fastcgi-2.4.2-poll.patch of Package apache2-mod_fastcgi
Index: mod_fastcgi-2.4.2/mod_fastcgi.c =================================================================== --- mod_fastcgi-2.4.2.orig/mod_fastcgi.c 2006-11-29 21:13:41.000000000 +0100 +++ mod_fastcgi-2.4.2/mod_fastcgi.c 2006-11-30 00:26:09.000000000 +0100 @@ -85,6 +85,8 @@ #endif #endif +#include <sys/poll.h> + #ifndef timersub #define timersub(a, b, result) \ do { \ @@ -1057,8 +1059,7 @@ static void send_request_complete(fcgi_r */ static int open_connection_to_fs(fcgi_request *fr) { - struct timeval tval; - fd_set write_fds, read_fds; + struct pollfd pollfds[1]; int status; request_rec * const r = fr->r; pool * const rp = r->pool; @@ -1356,17 +1357,6 @@ static int open_connection_to_fs(fcgi_re return FCGI_FAILED; } -#ifndef WIN32 - if (fr->fd >= FD_SETSIZE) { - ap_log_rerror(FCGI_LOG_ERR, r, - "FastCGI: failed to connect to server \"%s\": " - "socket file descriptor (%u) is larger than " - "FD_SETSIZE (%u), you probably need to rebuild Apache with a " - "larger FD_SETSIZE", fr->fs_path, fr->fd, FD_SETSIZE); - return FCGI_FAILED; - } -#endif - /* If appConnectTimeout is non-zero, setup do a non-blocking connect */ if ((fr->dynamic && dynamicAppConnectTimeout) || (!fr->dynamic && fr->fs->appConnectTimeout)) { set_nonblocking(fr, TRUE); @@ -1416,13 +1406,10 @@ static int open_connection_to_fs(fcgi_re if (fr->dynamic) { do { - FD_ZERO(&write_fds); - FD_SET(fr->fd, &write_fds); - read_fds = write_fds; - tval.tv_sec = dynamicPleaseStartDelay; - tval.tv_usec = 0; + pollfds[0].fd = fr->fd; + pollfds[0].events = POLLIN | POLLOUT; - status = ap_select((fr->fd+1), &read_fds, &write_fds, NULL, &tval); + status = poll(pollfds, 1, dynamicPleaseStartDelay * 1000); if (status < 0) break; @@ -1431,7 +1418,7 @@ static int open_connection_to_fs(fcgi_re if (status > 0) break; - /* select() timed out */ + /* poll() timed out */ send_to_pm(FCGI_REQUEST_TIMEOUT_JOB, fr->fs_path, fr->user, fr->group, 0, 0); } while ((fr->queueTime.tv_sec - fr->startTime.tv_sec) < (int)dynamicAppConnectTimeout); @@ -1445,13 +1432,10 @@ static int open_connection_to_fs(fcgi_re } } /* dynamic */ else { - tval.tv_sec = fr->fs->appConnectTimeout; - tval.tv_usec = 0; - FD_ZERO(&write_fds); - FD_SET(fr->fd, &write_fds); - read_fds = write_fds; + pollfds[0].fd = fr->fd; + pollfds[0].events = POLLIN | POLLOUT; - status = ap_select((fr->fd+1), &read_fds, &write_fds, NULL, &tval); + status = poll(pollfds, 1, fr->fs->appConnectTimeout * 1000); if (status == 0) { ap_log_rerror(FCGI_LOG_ERR_NOERRNO, r, @@ -1468,11 +1452,11 @@ static int open_connection_to_fs(fcgi_re #endif ap_log_rerror(FCGI_LOG_ERR_ERRNO, r, "FastCGI: failed to connect to server \"%s\": " - "select() failed", fr->fs_path); + "poll() failed", fr->fs_path); return FCGI_FAILED; } - if (FD_ISSET(fr->fd, &write_fds) || FD_ISSET(fr->fd, &read_fds)) { + if ((pollfds[0].revents & POLLIN) || pollfds[0].revents & POLLOUT) { int error = 0; NET_SIZE_T len = sizeof(error); @@ -1483,7 +1467,7 @@ static int open_connection_to_fs(fcgi_re #endif ap_log_rerror(FCGI_LOG_ERR_ERRNO, r, "FastCGI: failed to connect to server \"%s\": " - "select() failed (Solaris pending error)", fr->fs_path); + "poll() failed (Solaris pending error)", fr->fs_path); return FCGI_FAILED; } @@ -1492,7 +1476,7 @@ static int open_connection_to_fs(fcgi_re errno = error; ap_log_rerror(FCGI_LOG_ERR_ERRNO, r, "FastCGI: failed to connect to server \"%s\": " - "select() failed (pending error)", fr->fs_path); + "poll() failed (pending error)", fr->fs_path); return FCGI_FAILED; } } @@ -1502,7 +1486,7 @@ static int open_connection_to_fs(fcgi_re #endif ap_log_rerror(FCGI_LOG_ERR_ERRNO, r, "FastCGI: failed to connect to server \"%s\": " - "select() error - THIS CAN'T HAPPEN!", fr->fs_path); + "poll() error - THIS CAN'T HAPPEN!", fr->fs_path); return FCGI_FAILED; } @@ -1977,10 +1961,8 @@ static int socket_io(fcgi_request * cons struct timeval timeout; struct timeval dynamic_last_io_time = {0, 0}; - fd_set read_set; - fd_set write_set; - int nfds = 0; - int select_status = 1; + struct pollfd pollfds[2]; + int poll_status = 1; int idle_timeout; int rv; int dynamic_first_recv = fr->dynamic ? 1 : 0; @@ -2015,9 +1997,8 @@ static int socket_io(fcgi_request * cons for (;;) { - FD_ZERO(&read_set); - FD_ZERO(&write_set); - + pollfds[0].events = 0; + pollfds[1].events = 0; switch (state) { case STATE_ENV_SEND: @@ -2060,12 +2041,12 @@ SERVER_SEND: set_nonblocking(fr, TRUE); is_connected = 1; - nfds = fr->fd + 1; } if (BufferLength(fr->serverOutputBuffer)) { - FD_SET(fr->fd, &write_set); + pollfds[0].fd = fr->fd; + pollfds[0].events = POLLOUT; } else { @@ -2077,7 +2058,8 @@ SERVER_SEND: case STATE_SERVER_RECV: - FD_SET(fr->fd, &read_set); + pollfds[1].fd = fr->fd; + pollfds[1].events = POLLIN; /* fall through */ @@ -2126,7 +2108,7 @@ SERVER_SEND: fcgi_util_ticks(&fr->queueTime); - if (select_status) + if (poll_status) { /* a send() succeeded last pass */ dynamic_last_io_time = fr->queueTime; @@ -2178,19 +2160,22 @@ SERVER_SEND: } /* wait on the socket */ - select_status = ap_select(nfds, &read_set, &write_set, NULL, &timeout); + //ap_log_rerror(FCGI_LOG_ERR_NOERRNO, r, "FastCGI: polling with timeout %d msec", + //timeout.tv_sec * 1000 + timeout.tv_usec); + poll_status = poll(pollfds, 2, timeout.tv_sec * 1000 + timeout.tv_usec / 1000); + //ap_log_rerror(FCGI_LOG_ERR_NOERRNO, r, "FastCGI: poll returned with status %d", poll_status); - if (select_status < 0) + if (poll_status < 0) { ap_log_rerror(FCGI_LOG_ERR_ERRNO, r, "FastCGI: comm with server " - "\"%s\" aborted: select() failed", fr->fs_path); + "\"%s\" aborted: poll() failed", fr->fs_path); state = STATE_ERROR; break; } - if (select_status == 0) + if (poll_status == 0) { - /* select() timeout */ + /* poll() timeout */ if (BufferLength(fr->clientOutputBuffer)) { @@ -2220,8 +2205,13 @@ SERVER_SEND: } } - if (FD_ISSET(fr->fd, &write_set)) + if (! ((pollfds[0].revents & POLLOUT) || (pollfds[1].revents & POLLIN)) ) { + ap_log_rerror(FCGI_LOG_ERR, r, "FastCGI: neither POLLIN nor POLLOUT..."); + } + + if (pollfds[0].revents & POLLOUT) { + /* ap_log_rerror(FCGI_LOG_ERR, r, "FastCGI: POLLOUT"); */ /* send to the server */ rv = fcgi_buf_socket_send(fr->serverOutputBuffer, fr->fd); @@ -2235,8 +2225,9 @@ SERVER_SEND: } } - if (FD_ISSET(fr->fd, &read_set)) + if (pollfds[1].revents & POLLIN) { + /* ap_log_rerror(FCGI_LOG_ERR, r, "FastCGI: POLLIN"); */ /* recv from the server */ if (dynamic_first_recv)