httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject new directive: ReceiveBufferSize
Date Thu, 08 Sep 2005 18:25:35 GMT
Murray Nesbitt has submitted a request for a new feature 
ReceiveBufferSize: http://issues.apache.org/bugzilla/show_bug.cgi?id=36038

<QOUTE>
The SendBufferSize directive, which is used to adjust the TCP send buffer 
size, has existed for many years, but it would appear there has been no 
pressing need for a companion directive to control the size of the TCP 
receive buffer.  We have written an application that requires the ability 
to adjust the size of this buffer.

I have tried using apr_socket_opt_set, unfortunately the buffer size must 
be modified prior to connect() or accept() (at least on Linux...).
</QUOTE>

I've attached the code part of his patch
(The complete unwrapped patch including docs update can be found here:
http://issues.apache.org/bugzilla/attachment.cgi?id=15898)

Any objections to committing this new feature?

--- httpd-2.0.54/include/ap_listen.h.orig	2005-08-04 15:28:37.000000000 -0700
+++ httpd-2.0.54/include/ap_listen.h	2005-08-04 18:20:56.000000000 -0700
@@ -102,6 +102,8 @@
  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);
+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 +111,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
--- httpd-2.0.54/server/listen.c.orig	2005-02-04 12:21:18.000000000 -0800
+++ httpd-2.0.54/server/listen.c	2005-08-04 18:12:19.000000000 -0700
@@ -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);
@@ -462,3 +473,21 @@
      send_buffer_size = s;
      return NULL;
  }
+
+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;
+}

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://mailchannels.com

Mime
View raw message