Make the value set for the socket option TCP_DEFER_ACCEPT configurable
* include/ap_listen.h:
- Add prototype for ap_set_listentcpdeferaccept
- Wire in new directive ListenTCPDeferAccept
* include/mpm_common.h:
Define the previous static value as default value via DEFAULT_TCP_DEFER_ACCEPT
* server/listen.c:
- Add static int ap_listentcpdeferaccept
- ap_apply_accept_filter: Use value of ap_listenbacklog for setting TCP_DEFER_ACCEPT
- ap_listen_pre_config: Set default value
- Add ap_set_listentcpdeferaccept
* Follow up to r1927885: Use correct configuration variable. Thanks to @ylavic
for finding this.
* Follow up to r1927885: Changelog entry and documentation
Reviewed by: rpluem, jorton, covener
Github: closes #555
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@
1929574 13f79535-47bb-0310-9956-
ffa450edef68
-*- coding: utf-8 -*-
Changes with Apache 2.4.66
+ *) mpm_common: Add new ListenTCPDeferAccept directive that allows to specify
+ the value set for the TCP_DEFER_ACCEPT socket option on listen sockets.
+ [Ruediger Pluem]
+
*) mod_ssl: Add SSLVHostSNIPolicy directive to control the virtual
host compatibility policy. PR 69743. [Joe Orton]
2.4.x patch: svn merge -c 1927792 ^/httpd/httpd/trunk .
+1: icing, rpluem, jorton
- *) mpm_common: Add new ListenTCPDeferAccept directive that allows to specify
- the value set for the TCP_DEFER_ACCEPT socket option on listen sockets.
- Trunk version of patch:
- https://svn.apache.org/r1927885
- https://svn.apache.org/r1927916
- https://svn.apache.org/r1928022
- Backport version for 2.4.x of patch:
- https://patch-diff.githubusercontent.com/raw/apache/httpd/pull/555.diff
- Can be applied via apply_backport_pr.sh 555
- +1: rpluem, jorton, covener
-
*) mod_http2: Fix handling of 304 responses from mod_cache. PR 69580.
Trunk version of patch:
https://svn.apache.org/r1924267
</usage>
</directivesynopsis>
+<directivesynopsis>
+<name>ListenTCPDeferAccept</name>
+<description>Value set for the socket option TCP_DEFER_ACCEPT if it is set</description>
+<syntax>ListenTCPDeferAccept <var>integer</var></syntax>
+<default>ListenTCPDeferAccept 30</default>
+<contextlist><context>server config</context></contextlist>
+<modulelist><module>event</module><module>worker</module>
+<module>prefork</module>
+</modulelist>
+<compatibility>Available in Apache HTTP Server 2.5.1 and later</compatibility>
+
+<usage>
+ <p>The value specified here is set as a value for the socket option
+ <code>TCP_DEFER_ACCEPT</code> if it is set on the listen socket.
+ This happens when running on Linux and <directive
+ module="core">AcceptFilter</directive> is set to anything besides
+ <code>none</code>. In any other cases this setting is ignored.
+ For more details see the Linux
+ <a href="http://man7.org/linux/man-pages/man7/tcp.7.html">
+ tcp(7)</a> man page.</p>
+</usage>
+</directivesynopsis>
+
<directivesynopsis>
<name>MaxRequestWorkers</name>
<description>Maximum number of connections that will be processed
* called.
*/
AP_DECLARE_NONSTD(const char *) ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg);
+AP_DECLARE_NONSTD(const char *) ap_set_listentcpdeferaccept(cmd_parms *cmd, void *dummy, const char *arg);
AP_DECLARE_NONSTD(const char *) ap_set_listencbratio(cmd_parms *cmd, void *dummy, const char *arg);
AP_DECLARE_NONSTD(const char *) ap_set_listener(cmd_parms *cmd, void *dummy,
int argc, char *const argv[]);
AP_INIT_TAKE1("SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, \
"Send buffer size in bytes"), \
AP_INIT_TAKE1("ReceiveBufferSize", ap_set_receive_buffer_size, NULL, \
- RSRC_CONF, "Receive buffer size in bytes")
+ RSRC_CONF, "Receive buffer size in bytes"), \
+AP_INIT_TAKE1("ListenTCPDeferAccept", ap_set_listentcpdeferaccept, NULL, RSRC_CONF, \
+ "Value set for the socket option TCP_DEFER_ACCEPT if it is set")
#ifdef __cplusplus
}
#define DEFAULT_LISTENBACKLOG 511
#endif
+/*
+ * Define the default value set for the socket option TCP_DEFER_ACCEPT
+ * if it is set.
+ */
+#ifndef DEFAULT_TCP_DEFER_ACCEPT
+#define DEFAULT_TCP_DEFER_ACCEPT 30
+#endif
+
/* Signal used to gracefully restart */
#define AP_SIG_GRACEFUL SIGUSR1
static ap_listen_rec *old_listeners;
static int ap_listenbacklog;
+static int ap_listentcpdeferaccept;
static int ap_listencbratio;
static int send_buffer_size;
static int receive_buffer_size;
accf);
}
#else
- rv = apr_socket_opt_set(s, APR_TCP_DEFER_ACCEPT, 30);
+ rv = apr_socket_opt_set(s, APR_TCP_DEFER_ACCEPT, ap_listentcpdeferaccept);
if (rv != APR_SUCCESS && !APR_STATUS_IS_ENOTIMPL(rv)) {
ap_log_perror(APLOG_MARK, APLOG_WARNING, rv, p, APLOGNO(00076)
"Failed to enable APR_TCP_DEFER_ACCEPT");
ap_listen_buckets = NULL;
ap_num_listen_buckets = 0;
ap_listenbacklog = DEFAULT_LISTENBACKLOG;
+ ap_listentcpdeferaccept = DEFAULT_TCP_DEFER_ACCEPT;
ap_listencbratio = 0;
/* Check once whether or not SO_REUSEPORT is supported. */
return NULL;
}
+AP_DECLARE_NONSTD(const char *) ap_set_listentcpdeferaccept(cmd_parms *cmd,
+ void *dummy,
+ const char *arg)
+{
+ int b;
+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+
+ if (err != NULL) {
+ return err;
+ }
+
+ b = atoi(arg);
+ if (b < 1) {
+ return "ListenTCPDeferAccept must be > 0";
+ }
+
+ ap_listentcpdeferaccept = b;
+ return NULL;
+}
+
AP_DECLARE_NONSTD(const char *) ap_set_listencbratio(cmd_parms *cmd,
void *dummy,
const char *arg)