From 03730c671abd2510d1c6362e7b36a5fe9d97e315 Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Fri, 23 Jun 2000 20:23:08 +0000 Subject: [PATCH] Fix a couple of problems associated with recognizing when file descriptors for connected sockets are too big. Todo: The BeOS MPMs seem to have the same issue. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85679 13f79535-47bb-0310-9956-ffa450edef68 --- server/mpm/dexter/dexter.c | 23 +++++++---------- server/mpm/mpmt_pthread/mpmt_pthread.c | 24 ++++++++---------- server/mpm/prefork/prefork.c | 35 +++++++++++--------------- 3 files changed, 34 insertions(+), 48 deletions(-) diff --git a/server/mpm/dexter/dexter.c b/server/mpm/dexter/dexter.c index 1988598177..87a62c0f0a 100644 --- a/server/mpm/dexter/dexter.c +++ b/server/mpm/dexter/dexter.c @@ -497,24 +497,19 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, long conn_id) if ((rv = ap_get_os_sock(&csd, sock)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "ap_get_os_sock"); } - sock_disable_nagle(csd); - iol = unix_attach_socket(sock); - if (iol == NULL) { - if (errno == EBADF) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, errno, NULL, - "filedescriptor (%u) larger than FD_SETSIZE (%u) " - "found, you probably need to rebuild Apache with a " - "larger FD_SETSIZE", csd, FD_SETSIZE); - } - else { - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL, - "error attaching to socket"); - } + if (csd >= FD_SETSIZE) { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL, + "new file descriptor %d is too large; you probably need " + "to rebuild Apache with a larger FD_SETSIZE " + "(currently %d)", + csd, FD_SETSIZE); ap_close_socket(sock); - return; + return; } + sock_disable_nagle(csd); + iol = unix_attach_socket(sock); conn_io = ap_bcreate(p, B_RDWR); ap_bpush_iol(conn_io, iol); diff --git a/server/mpm/mpmt_pthread/mpmt_pthread.c b/server/mpm/mpmt_pthread/mpmt_pthread.c index 72abaa5e92..f4aa7a92e1 100644 --- a/server/mpm/mpmt_pthread/mpmt_pthread.c +++ b/server/mpm/mpmt_pthread/mpmt_pthread.c @@ -492,23 +492,19 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, int my_child_num, in (void) ap_get_os_sock(&csd, sock); + if (csd >= FD_SETSIZE) { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL, + "new file descriptor %d is too large; you probably need " + "to rebuild Apache with a larger FD_SETSIZE " + "(currently %d)", + csd, FD_SETSIZE); + ap_close_socket(sock); + return; + } + sock_disable_nagle(csd); iol = unix_attach_socket(sock); - if (iol == NULL) { - if (errno == EBADF) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL, - "filedescriptor (%u) larger than FD_SETSIZE (%u) " - "found, you probably need to rebuild Apache with a " - "larger FD_SETSIZE", csd, FD_SETSIZE); - } - else { - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL, - "error attaching to socket"); - } - ap_close_socket(sock); - return; - } (void) ap_update_child_status(my_child_num, my_thread_num, SERVER_BUSY_READ, (request_rec *) NULL); diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index d27be5b0e1..107238da03 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -1003,11 +1003,6 @@ static void child_main(int child_num_arg) SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */ -#ifdef TPF - if (csd == 0) /* 0 is invalid socket for TPF */ - continue; -#endif - /* We've got a socket, let's at least process one request off the * socket before we accept a graceful restart request. We set * the signal to ignore because we don't want to disturb any @@ -1021,24 +1016,24 @@ static void child_main(int child_num_arg) ap_get_os_sock(&sockdes, csd); - sock_disable_nagle(sockdes); - - iol = unix_attach_socket(csd); - if (iol == NULL) { - if (errno == EBADF) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL, - "filedescriptor (%u) larger than FD_SETSIZE (%u) " - "found, you probably need to rebuild Apache with a " - "larger FD_SETSIZE", sockdes, FD_SETSIZE); - } - else { - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL, - "error attaching to socket"); - } + if (sockdes >= FD_SETSIZE) { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL, + "new file descriptor %d is too large; you probably need " + "to rebuild Apache with a larger FD_SETSIZE " + "(currently %d)", + sockdes, FD_SETSIZE); ap_close_socket(csd); continue; - } + } +#ifdef TPF + if (sockdes == 0) /* 0 is invalid socket for TPF */ + continue; +#endif + + sock_disable_nagle(sockdes); + + iol = unix_attach_socket(csd); (void) ap_update_child_status(my_child_num, SERVER_BUSY_READ, (request_rec *) NULL); -- 2.40.0