You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2006/01/23 20:49:22 UTC

svn commit: r371640 - in /httpd/httpd/branches/2.0.x: CHANGES STATUS include/ap_listen.h server/listen.c

Author: colm
Date: Mon Jan 23 11:49:13 2006
New Revision: 371640

URL: http://svn.apache.org/viewcvs?rev=371640&view=rev
Log:
Merge r157583 from trunk:

Add ReceiveBufferSize directive to control the TCP receive buffer.

Submitted by: Eric Covener <covener gmail.com>
Reviewed by:  Justin Erenkrantz (with minor formatting tweaks)

Modified:
    httpd/httpd/branches/2.0.x/CHANGES
    httpd/httpd/branches/2.0.x/STATUS
    httpd/httpd/branches/2.0.x/include/ap_listen.h
    httpd/httpd/branches/2.0.x/server/listen.c

Modified: httpd/httpd/branches/2.0.x/CHANGES
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.0.x/CHANGES?rev=371640&r1=371639&r2=371640&view=diff
==============================================================================
--- httpd/httpd/branches/2.0.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.0.x/CHANGES [utf-8] Mon Jan 23 11:49:13 2006
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.0.56
 
+  *) Add ReceiveBufferSize directive to control the TCP receive buffer.
+     [Eric Covener <covener gmail.com>]
+
   *) mod_cache: Fix 'Vary: *' behavior to be RFC compliant. PR 16125.
      [Paul Querna]
 

Modified: httpd/httpd/branches/2.0.x/STATUS
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.0.x/STATUS?rev=371640&r1=371639&r2=371640&view=diff
==============================================================================
--- httpd/httpd/branches/2.0.x/STATUS (original)
+++ httpd/httpd/branches/2.0.x/STATUS Mon Jan 23 11:49:13 2006
@@ -141,12 +141,6 @@
        +1: trawick, wrowe, colm
         backported 280114 to 2.2.x branch already
 
-    *) Add ReceiveBufferSize directive to control the TCP receive buffer. 
-       code: http://svn.apache.org/viewcvs?view=rev&rev=157583
-             http://svn.apache.org/viewcvs?rev=280401&view=rev
-       docs: http://svn.apache.org/viewcvs?rev=280384&view=rev
-       +1: stas, trawick, colm
-
     *) mod_dav: Fix a null pointer dereference in an error code path during the
        handling of MKCOL.
        Trunk version of patch:

Modified: httpd/httpd/branches/2.0.x/include/ap_listen.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.0.x/include/ap_listen.h?rev=371640&r1=371639&r2=371640&view=diff
==============================================================================
--- httpd/httpd/branches/2.0.x/include/ap_listen.h (original)
+++ httpd/httpd/branches/2.0.x/include/ap_listen.h Mon Jan 23 11:49:13 2006
@@ -102,6 +102,9 @@
 const char *ap_set_listener(cmd_parms *cmd, void *dummy, const char *ips);
 const char *ap_set_send_buffer_size(cmd_parms *cmd, void *dummy,
 				    const char *arg);
+AP_DECLARE_NONSTD(const char *) ap_set_receive_buffer_size(cmd_parms *cmd,
+                                                           void *dummy,
+                                                           const char *arg);
 
 #define LISTEN_COMMANDS	\
 AP_INIT_TAKE1("ListenBacklog", ap_set_listenbacklog, NULL, RSRC_CONF, \
@@ -109,6 +112,8 @@
 AP_INIT_TAKE1("Listen", ap_set_listener, NULL, RSRC_CONF, \
   "A port number or a numeric IP address and a port number"), \
 AP_INIT_TAKE1("SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, \
-  "Send buffer size in bytes")
+  "Send buffer size in bytes"), \
+AP_INIT_TAKE1("ReceiveBufferSize", ap_set_receive_buffer_size, NULL, \
+              RSRC_CONF, "Receive buffer size in bytes")
 
 #endif

Modified: httpd/httpd/branches/2.0.x/server/listen.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.0.x/server/listen.c?rev=371640&r1=371639&r2=371640&view=diff
==============================================================================
--- httpd/httpd/branches/2.0.x/server/listen.c (original)
+++ httpd/httpd/branches/2.0.x/server/listen.c Mon Jan 23 11:49:13 2006
@@ -40,6 +40,7 @@
 static ap_listen_rec *old_listeners;
 static int ap_listenbacklog;
 static int send_buffer_size;
+static int receive_buffer_size;
 
 /* TODO: make_sock is just begging and screaming for APR abstraction */
 static apr_status_t make_sock(apr_pool_t *p, ap_listen_rec *server)
@@ -118,6 +119,16 @@
             /* not a fatal error */
         }
     }
+    if (receive_buffer_size) {
+        stat = apr_socket_opt_set(s, APR_SO_RCVBUF, receive_buffer_size);
+        if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
+            ap_log_perror(APLOG_MARK, APLOG_WARNING, stat, p,
+                          "make_sock: failed to set ReceiveBufferSize for "
+                          "address %pI, using default",
+                          server->bind_addr);
+            /* not a fatal error */
+        }
+    }
 
 #if APR_TCP_NODELAY_INHERITED
     ap_sock_disable_nagle(s);
@@ -460,5 +471,24 @@
     }
 
     send_buffer_size = s;
+    return NULL;
+}
+
+AP_DECLARE_NONSTD(const char *) ap_set_receive_buffer_size(cmd_parms *cmd,
+                                                           void *dummy,
+                                                           const char *arg)
+{
+    int s = atoi(arg);
+    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+
+    if (err != NULL) {
+        return err;
+    }
+
+    if (s < 512 && s != 0) {
+        return "ReceiveBufferSize must be >= 512 bytes, or 0 for system default.";
+    }
+
+    receive_buffer_size = s;
     return NULL;
 }