Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/ap_listen.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ AP_DECLARE_NONSTD(int) ap_close_selected_listeners(ap_slave_t *);
* 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[]);
Expand Down Expand Up @@ -163,7 +164,9 @@ AP_INIT_TAKE_ARGV("Listen", ap_set_listener, NULL, RSRC_CONF, \
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
}
Expand Down
8 changes: 8 additions & 0 deletions include/mpm_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ extern "C" {
#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

Expand Down
24 changes: 23 additions & 1 deletion server/listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ AP_DECLARE_DATA int ap_have_so_reuseport = -1;

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;
Expand Down Expand Up @@ -268,7 +269,7 @@ static void ap_apply_accept_filter(apr_pool_t *p, ap_listen_rec *lis,
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");
Expand Down Expand Up @@ -947,6 +948,7 @@ AP_DECLARE(void) ap_listen_pre_config(void)
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. */
Expand Down Expand Up @@ -1076,6 +1078,26 @@ AP_DECLARE_NONSTD(const char *) ap_set_listenbacklog(cmd_parms *cmd,
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)
Expand Down
Loading