Apache2
ap_listen.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
26 #ifndef AP_LISTEN_H
27 #define AP_LISTEN_H
28 
29 #include "apr_network_io.h"
30 #include "httpd.h"
31 #include "http_config.h"
32 #include "apr_optional.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 typedef struct ap_slave_t ap_slave_t;
39 typedef struct ap_listen_rec ap_listen_rec;
40 typedef apr_status_t (*accept_function)(void **csd, ap_listen_rec *lr, apr_pool_t *ptrans);
41 
42 /* Flags for ap_listen_rec.flags */
43 #define AP_LISTEN_SPECIFIC_ERRORS (0x0001)
44 #define AP_LISTEN_FREEBIND (0x0002)
45 #define AP_LISTEN_REUSEPORT (0x0004)
46 #define AP_LISTEN_V6ONLY (0x0008)
47 
54 struct ap_listen_rec {
74  int active;
78  const char* protocol;
79 
81 
86 };
87 
95 
97 
102 
110 
125  ap_listen_rec ***buckets,
126  int *num_buckets);
127 
132 
138 
143 
144 /* Although these functions are exported from libmain, they are not really
145  * public functions. These functions are actually called while parsing the
146  * config file, when one of the LISTEN_COMMANDS directives is read. These
147  * should not ever be called by external modules. ALL MPMs should include
148  * LISTEN_COMMANDS in their command_rec table so that these functions are
149  * called.
150  */
151 AP_DECLARE_NONSTD(const char *) ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg);
152 AP_DECLARE_NONSTD(const char *) ap_set_listencbratio(cmd_parms *cmd, void *dummy, const char *arg);
153 AP_DECLARE_NONSTD(const char *) ap_set_listener(cmd_parms *cmd, void *dummy,
154  int argc, char *const argv[]);
155 AP_DECLARE_NONSTD(const char *) ap_set_send_buffer_size(cmd_parms *cmd, void *dummy,
156  const char *arg);
158  void *dummy,
159  const char *arg);
160 
162  void *dummy,
163  int flag);
164 
165 #ifdef HAVE_SYSTEMD
167  ap_find_systemd_socket, (process_rec *, apr_port_t));
168 
170  ap_systemd_listen_fds, (int));
171 #endif
172 
173 
174 #define LISTEN_COMMANDS \
175 AP_INIT_TAKE1("ListenBacklog", ap_set_listenbacklog, NULL, RSRC_CONF, \
176  "Maximum length of the queue of pending connections, as used by listen(2)"), \
177 AP_INIT_TAKE1("ListenCoresBucketsRatio", ap_set_listencbratio, NULL, RSRC_CONF, \
178  "Ratio between the number of CPU cores (online) and the number of listeners buckets"), \
179 AP_INIT_TAKE_ARGV("Listen", ap_set_listener, NULL, RSRC_CONF, \
180  "A port number or a numeric IP address and a port number, and an optional protocol"), \
181 AP_INIT_TAKE1("SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, \
182  "Send buffer size in bytes"), \
183 AP_INIT_TAKE1("ReceiveBufferSize", ap_set_receive_buffer_size, NULL, \
184  RSRC_CONF, "Receive buffer size in bytes"), \
185 AP_INIT_FLAG("AcceptErrorsNonFatal", ap_set_accept_errors_nonfatal, NULL, \
186  RSRC_CONF, "Some accept() errors are not fatal to the process")
187 #ifdef __cplusplus
188 }
189 #endif
190 
191 #endif
APR Network library.
APR-UTIL registration of functions exported by modules.
struct ap_slave_t ap_slave_t
Definition: ap_listen.h:38
AP_DECLARE_DATA int ap_num_listen_buckets
void ap_close_listeners(void)
const char * ap_set_listener(cmd_parms *cmd, void *dummy, int argc, char *const argv[])
const char * ap_set_receive_buffer_size(cmd_parms *cmd, void *dummy, const char *arg)
AP_DECLARE_DATA int ap_accept_errors_nonfatal
const char * ap_set_accept_errors_nonfatal(cmd_parms *cmd, void *dummy, int flag)
AP_DECLARE_DATA ap_listen_rec * ap_listeners
AP_DECLARE_DATA int ap_have_so_reuseport
const char * ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg)
int ap_accept_error_is_nonfatal(apr_status_t rv)
const char * ap_set_send_buffer_size(cmd_parms *cmd, void *dummy, const char *arg)
apr_status_t(* accept_function)(void **csd, ap_listen_rec *lr, apr_pool_t *ptrans)
Definition: ap_listen.h:40
int ap_close_selected_listeners(ap_slave_t *)
void ap_close_listeners_ex(ap_listen_rec *listeners)
void ap_listen_pre_config(void)
apr_status_t ap_duplicate_listeners(apr_pool_t *p, server_rec *s, ap_listen_rec ***buckets, int *num_buckets)
const char * ap_set_listencbratio(cmd_parms *cmd, void *dummy, const char *arg)
int ap_setup_listeners(server_rec *s)
#define APR_DECLARE_OPTIONAL_FN(ret, name, args)
Definition: apr_optional.h:50
const char * s
Definition: mod_dav.h:1327
int apr_status_t
Definition: apr_errno.h:44
apr_uint16_t apr_port_t
Definition: apr_network_io.h:230
unsigned int apr_uint32_t
Definition: apr.h:348
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
Apache Configuration.
HTTP Daemon routines.
#define AP_DECLARE_DATA
Definition: macros.h:15
#define AP_DECLARE(x)
Definition: macros.h:1
#define AP_DECLARE_NONSTD(x)
Definition: macros.h:2
Apache's listeners record.
Definition: ap_listen.h:54
ap_listen_rec * next
Definition: ap_listen.h:58
int active
Definition: ap_listen.h:74
const char * protocol
Definition: ap_listen.h:78
ap_slave_t * slave
Definition: ap_listen.h:80
apr_uint32_t flags
Definition: ap_listen.h:85
accept_function accept_func
Definition: ap_listen.h:70
apr_sockaddr_t * bind_addr
Definition: ap_listen.h:66
apr_socket_t * sd
Definition: ap_listen.h:62
Definition: apr_network_io.h:239
Definition: apr_arch_networkio.h:37
Definition: http_config.h:288
A structure that represents one process.
Definition: httpd.h:840
A structure to store information for each virtual server.
Definition: httpd.h:1382
apr_pool_t * p