Return-Path: Delivered-To: apmail-new-httpd-archive@apache.org Received: (qmail 35604 invoked by uid 500); 21 Aug 2000 05:03:09 -0000 Mailing-List: contact new-httpd-help@apache.org; run by ezmlm Precedence: bulk X-No-Archive: yes Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list new-httpd@apache.org Received: (qmail 35592 invoked from network); 21 Aug 2000 05:03:04 -0000 Message-Id: <200008210502.PAA13605@silk.apana.org.au> From: "Brian Havard" To: "Apache Developers Mailing List" Date: Mon, 21 Aug 2000 15:03:15 +1000 (EST) Reply-To: "Brian Havard" Priority: Normal X-Mailer: PMMail 2.10.1999 for OS/2 Warp 4.05 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Subject: [PATCH] APRize nagle X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N The current ap_sock_disable_nagle() requires an OS handle. This patch makes it take an apr_socket_t * instead. Note that I had to stick my fingers into MPMs & APR code I can't test which is why I'm posting the patch before commiting it. Is this ok by everyone or do we need to keep the FD_SETSIZE test in there? I removed them because this removes the last use of the os socket in that part of the code. I'm doing this because (a) it's the right thing to do, and (b) is required to make OS/2 work right. Index: include/mpm_common.h =================================================================== RCS file: /home/cvs/apache-2.0/src/include/mpm_common.h,v retrieving revision 1.9 diff -u -r1.9 mpm_common.h --- include/mpm_common.h 2000/08/06 06:07:01 1.9 +++ include/mpm_common.h 2000/08/21 04:35:48 @@ -123,7 +123,7 @@ * Nagle's algorithm that have severe performance penalties. * @param s The socket to disable nagle for. */ -void ap_sock_disable_nagle(int s); +void ap_sock_disable_nagle(apr_socket_t *s); #else #define ap_sock_disable_nagle(s) /* NOOP */ #endif Index: lib/apr/include/apr_network_io.h =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_network_io.h,v retrieving revision 1.52 diff -u -r1.52 apr_network_io.h --- lib/apr/include/apr_network_io.h 2000/08/06 06:07:09 1.52 +++ lib/apr/include/apr_network_io.h 2000/08/21 04:35:57 @@ -92,6 +92,7 @@ #define APR_SO_SNDBUF 64 #define APR_SO_RCVBUF 128 #define APR_SO_DISCONNECTED 256 +#define APR_TCP_NODELAY 512 #define APR_POLLIN 0x001 #define APR_POLLPRI 0x002 Index: lib/apr/network_io/beos/sockopt.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/beos/sockopt.c,v retrieving revision 1.22 diff -u -r1.22 sockopt.c --- lib/apr/network_io/beos/sockopt.c 2000/08/02 05:26:26 1.22 +++ lib/apr/network_io/beos/sockopt.c 2000/08/21 04:36:03 @@ -107,6 +107,11 @@ sock->timeout = on; } + if (opt & APR_TCP_NODELAY) { + if (setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY, (void *)&on, sizeof(int)) == -1) { + return errno; + } + } return APR_SUCCESS; } Index: lib/apr/network_io/os2/sockopt.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/os2/sockopt.c,v retrieving revision 1.16 diff -u -r1.16 sockopt.c --- lib/apr/network_io/os2/sockopt.c 2000/08/06 16:35:54 1.16 +++ lib/apr/network_io/os2/sockopt.c 2000/08/21 04:36:04 @@ -114,6 +114,11 @@ if (opt & APR_SO_TIMEOUT) { sock->timeout = on; } + if (opt & APR_TCP_NODELAY) { + if (setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY, (void *)&on, sizeof(int)) == -1) { + return APR_OS2_STATUS(sock_errno()); + } + } return APR_SUCCESS; } Index: lib/apr/network_io/unix/sockopt.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/sockopt.c,v retrieving revision 1.32 diff -u -r1.32 sockopt.c --- lib/apr/network_io/unix/sockopt.c 2000/08/02 05:26:29 1.32 +++ lib/apr/network_io/unix/sockopt.c 2000/08/21 04:36:04 @@ -170,6 +170,11 @@ } sock->timeout = on; } + if (opt & APR_TCP_NODELAY) { + if (setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY, (void *)&on, sizeof(int)) == -1) { + return errno; + } + } return APR_SUCCESS; } Index: lib/apr/network_io/win32/sockopt.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/win32/sockopt.c,v retrieving revision 1.24 diff -u -r1.24 sockopt.c --- lib/apr/network_io/win32/sockopt.c 2000/08/17 20:26:29 1.24 +++ lib/apr/network_io/win32/sockopt.c 2000/08/21 04:36:04 @@ -157,6 +157,11 @@ } break; } + case APR_TCP_NODELAY: + if (setsockopt(sock->sock, IPPROTO_TCP, TCP_NODELAY, (void *)&on, sizeof(int)) == -1) { + return WSAGetLastError(); + } + break; default: return APR_EINVAL; break; Index: main/mpm_common.c =================================================================== RCS file: /home/cvs/apache-2.0/src/main/mpm_common.c,v retrieving revision 1.32 diff -u -r1.32 mpm_common.c --- main/mpm_common.c 2000/08/06 06:07:35 1.32 +++ main/mpm_common.c 2000/08/21 04:36:16 @@ -261,7 +261,7 @@ } #if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF) -void ap_sock_disable_nagle(int s) +void ap_sock_disable_nagle(apr_socket_t *s) { /* The Nagle algorithm says that we should delay sending partial * packets in hopes of getting more data. We don't want to do @@ -272,11 +272,10 @@ * * In spite of these problems, failure here is not a shooting offense. */ - int just_say_no = 1; + apr_status_t status = apr_setsocketopt(s, APR_TCP_NODELAY, 1); - if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &just_say_no, - sizeof(int)) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + if (status != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_WARNING, status, ap_server_conf, "setsockopt: (TCP_NODELAY)"); } } Index: modules/mpm/dexter/dexter.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/mpm/dexter/dexter.c,v retrieving revision 1.123 diff -u -r1.123 dexter.c --- modules/mpm/dexter/dexter.c 2000/08/06 06:07:39 1.123 +++ modules/mpm/dexter/dexter.c 2000/08/21 04:36:20 @@ -399,24 +399,8 @@ BUFF *conn_io; conn_rec *current_conn; ap_iol *iol; - int csd; - apr_status_t rv; - if ((rv = apr_get_os_sock(&csd, sock)) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "apr_get_os_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); - apr_close_socket(sock); - return; - } - - ap_sock_disable_nagle(csd); + ap_sock_disable_nagle(sock); iol = ap_iol_attach_socket(p, sock); conn_io = ap_bcreate(p, B_RDWR); ap_bpush_iol(conn_io, iol); Index: modules/mpm/mpmt_pthread/mpmt_pthread.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.118 diff -u -r1.118 mpmt_pthread.c --- modules/mpm/mpmt_pthread/mpmt_pthread.c 2000/08/06 06:07:40 1.118 +++ modules/mpm/mpmt_pthread/mpmt_pthread.c 2000/08/21 04:36:23 @@ -397,21 +397,8 @@ conn_rec *current_conn; ap_iol *iol; long conn_id = my_child_num * HARD_THREAD_LIMIT + my_thread_num; - int csd; - (void) apr_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); - apr_close_socket(sock); - return; - } - - ap_sock_disable_nagle(csd); + ap_sock_disable_nagle(sock); iol = ap_iol_attach_socket(p, sock); Index: modules/mpm/perchild/perchild.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/mpm/perchild/perchild.c,v retrieving revision 1.18 diff -u -r1.18 perchild.c --- modules/mpm/perchild/perchild.c 2000/08/06 21:17:33 1.18 +++ modules/mpm/perchild/perchild.c 2000/08/21 04:36:27 @@ -434,26 +434,11 @@ BUFF *conn_io; conn_rec *current_conn; ap_iol *iol; - int csd; apr_status_t rv; int thread_num = conn_id % HARD_THREAD_LIMIT; - if ((rv = apr_get_os_sock(&csd, sock)) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "apr_get_os_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); - apr_close_socket(sock); - return; - } - if (thread_socket_table[thread_num] < 0) { - ap_sock_disable_nagle(csd); + ap_sock_disable_nagle(sock); } iol = ap_iol_attach_socket(p, sock); conn_io = ap_bcreate(p, B_RDWR); Index: modules/mpm/prefork/prefork.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/mpm/prefork/prefork.c,v retrieving revision 1.125 diff -u -r1.125 prefork.c --- modules/mpm/prefork/prefork.c 2000/08/06 06:07:42 1.125 +++ modules/mpm/prefork/prefork.c 2000/08/21 04:36:33 @@ -1003,24 +1003,7 @@ * socket options, file descriptors, and read/write buffers. */ - apr_get_os_sock(&sockdes, csd); - - 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); - apr_close_socket(csd); - continue; - } - -#ifdef TPF - if (sockdes == 0) /* 0 is invalid socket for TPF */ - continue; -#endif - - ap_sock_disable_nagle(sockdes); + ap_sock_disable_nagle(csd); iol = ap_iol_attach_socket(ptrans, csd); (void) ap_update_child_status(my_child_num, SERVER_BUSY_READ, -- ______________________________________________________________________________ | Brian Havard | "He is not the messiah! | | brianh@kheldar.apana.org.au | He's a very naughty boy!" - Life of Brian | ------------------------------------------------------------------------------