|
Packit |
90a5c9 |
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
Packit |
90a5c9 |
* contributor license agreements. See the NOTICE file distributed with
|
|
Packit |
90a5c9 |
* this work for additional information regarding copyright ownership.
|
|
Packit |
90a5c9 |
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
Packit |
90a5c9 |
* (the "License"); you may not use this file except in compliance with
|
|
Packit |
90a5c9 |
* the License. You may obtain a copy of the License at
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
90a5c9 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
90a5c9 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
90a5c9 |
* See the License for the specific language governing permissions and
|
|
Packit |
90a5c9 |
* limitations under the License.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* @file ap_listen.h
|
|
Packit |
90a5c9 |
* @brief Apache Listeners Library
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* @defgroup APACHE_CORE_LISTEN Apache Listeners Library
|
|
Packit |
90a5c9 |
* @ingroup APACHE_CORE
|
|
Packit |
90a5c9 |
* @{
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#ifndef AP_LISTEN_H
|
|
Packit |
90a5c9 |
#define AP_LISTEN_H
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include "apr_network_io.h"
|
|
Packit |
90a5c9 |
#include "httpd.h"
|
|
Packit |
90a5c9 |
#include "http_config.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#ifdef __cplusplus
|
|
Packit |
90a5c9 |
extern "C" {
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef struct ap_slave_t ap_slave_t;
|
|
Packit |
90a5c9 |
typedef struct ap_listen_rec ap_listen_rec;
|
|
Packit |
90a5c9 |
typedef apr_status_t (*accept_function)(void **csd, ap_listen_rec *lr, apr_pool_t *ptrans);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* @brief Apache's listeners record.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* These are used in the Multi-Processing Modules
|
|
Packit |
90a5c9 |
* to setup all of the sockets for the MPM to listen to and accept on.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
struct ap_listen_rec {
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* The next listener in the list
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
ap_listen_rec *next;
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* The actual socket
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
apr_socket_t *sd;
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* The sockaddr the socket should bind to
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
apr_sockaddr_t *bind_addr;
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* The accept function for this socket
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
accept_function accept_func;
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* Is this socket currently active
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
int active;
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* The default protocol for this listening socket.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
const char* protocol;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
ap_slave_t *slave;
|
|
Packit |
90a5c9 |
};
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* The global list of ap_listen_rec structures
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
AP_DECLARE_DATA extern ap_listen_rec *ap_listeners;
|
|
Packit |
90a5c9 |
AP_DECLARE_DATA extern int ap_num_listen_buckets;
|
|
Packit |
90a5c9 |
AP_DECLARE_DATA extern int ap_have_so_reuseport;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* Setup all of the defaults for the listener list
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
AP_DECLARE(void) ap_listen_pre_config(void);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* Loop through the global ap_listen_rec list and create all of the required
|
|
Packit |
90a5c9 |
* sockets. This executes the listen and bind on the sockets.
|
|
Packit |
90a5c9 |
* @param s The global server_rec
|
|
Packit |
90a5c9 |
* @return The number of open sockets.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
AP_DECLARE(int) ap_setup_listeners(server_rec *s);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* This function duplicates ap_listeners into multiple buckets when configured
|
|
Packit |
90a5c9 |
* to (see ListenCoresBucketsRatio) and the platform supports it (eg. number of
|
|
Packit |
90a5c9 |
* online CPU cores and SO_REUSEPORT available).
|
|
Packit |
90a5c9 |
* @param p The config pool
|
|
Packit |
90a5c9 |
* @param s The global server_rec
|
|
Packit |
90a5c9 |
* @param buckets The array of listeners buckets.
|
|
Packit |
90a5c9 |
* @param num_buckets The total number of listeners buckets (array size).
|
|
Packit |
90a5c9 |
* @remark If the given *num_buckets is 0 (input), it will be computed
|
|
Packit |
90a5c9 |
* according to the platform capacities, otherwise (positive) it
|
|
Packit |
90a5c9 |
* will be preserved. The number of listeners duplicated will
|
|
Packit |
90a5c9 |
* always match *num_buckets, be it computed or given.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
AP_DECLARE(apr_status_t) ap_duplicate_listeners(apr_pool_t *p, server_rec *s,
|
|
Packit |
90a5c9 |
ap_listen_rec ***buckets,
|
|
Packit |
90a5c9 |
int *num_buckets);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* Loop through the global ap_listen_rec list and close each of the sockets.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
AP_DECLARE_NONSTD(void) ap_close_listeners(void);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* Loop through the given ap_listen_rec list and close each of the sockets.
|
|
Packit |
90a5c9 |
* @param listeners The listener to close.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
AP_DECLARE_NONSTD(void) ap_close_listeners_ex(ap_listen_rec *listeners);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* FIXMEDOC
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
AP_DECLARE_NONSTD(int) ap_close_selected_listeners(ap_slave_t *);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Although these functions are exported from libmain, they are not really
|
|
Packit |
90a5c9 |
* public functions. These functions are actually called while parsing the
|
|
Packit |
90a5c9 |
* config file, when one of the LISTEN_COMMANDS directives is read. These
|
|
Packit |
90a5c9 |
* should not ever be called by external modules. ALL MPMs should include
|
|
Packit |
90a5c9 |
* LISTEN_COMMANDS in their command_rec table so that these functions are
|
|
Packit |
90a5c9 |
* called.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
AP_DECLARE_NONSTD(const char *) ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg);
|
|
Packit |
90a5c9 |
AP_DECLARE_NONSTD(const char *) ap_set_listencbratio(cmd_parms *cmd, void *dummy, const char *arg);
|
|
Packit |
90a5c9 |
AP_DECLARE_NONSTD(const char *) ap_set_listener(cmd_parms *cmd, void *dummy,
|
|
Packit |
90a5c9 |
int argc, char *const argv[]);
|
|
Packit |
90a5c9 |
AP_DECLARE_NONSTD(const char *) ap_set_send_buffer_size(cmd_parms *cmd, void *dummy,
|
|
Packit |
90a5c9 |
const char *arg);
|
|
Packit |
90a5c9 |
AP_DECLARE_NONSTD(const char *) ap_set_receive_buffer_size(cmd_parms *cmd,
|
|
Packit |
90a5c9 |
void *dummy,
|
|
Packit |
90a5c9 |
const char *arg);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define LISTEN_COMMANDS \
|
|
Packit |
90a5c9 |
AP_INIT_TAKE1("ListenBacklog", ap_set_listenbacklog, NULL, RSRC_CONF, \
|
|
Packit |
90a5c9 |
"Maximum length of the queue of pending connections, as used by listen(2)"), \
|
|
Packit |
90a5c9 |
AP_INIT_TAKE1("ListenCoresBucketsRatio", ap_set_listencbratio, NULL, RSRC_CONF, \
|
|
Packit |
90a5c9 |
"Ratio between the number of CPU cores (online) and the number of listeners buckets"), \
|
|
Packit |
90a5c9 |
AP_INIT_TAKE_ARGV("Listen", ap_set_listener, NULL, RSRC_CONF, \
|
|
Packit |
90a5c9 |
"A port number or a numeric IP address and a port number, and an optional protocol"), \
|
|
Packit |
90a5c9 |
AP_INIT_TAKE1("SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, \
|
|
Packit |
90a5c9 |
"Send buffer size in bytes"), \
|
|
Packit |
90a5c9 |
AP_INIT_TAKE1("ReceiveBufferSize", ap_set_receive_buffer_size, NULL, \
|
|
Packit |
90a5c9 |
RSRC_CONF, "Receive buffer size in bytes")
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#ifdef __cplusplus
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
/** @} */
|