bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / include / ap_listen.h
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
17 #ifndef AP_LISTEN_H
18 #define AP_LISTEN_H
19
20 #include "apr_network_io.h"
21 #include "httpd.h"
22 #include "http_config.h"
23
24 /**
25  * @package Apache Listeners Library
26  */
27
28 typedef struct ap_listen_rec ap_listen_rec;
29 typedef apr_status_t (*accept_function)(void **csd, ap_listen_rec *lr, apr_pool_t *ptrans);
30
31 /**
32  * Apache's listeners record.  These are used in the Multi-Processing Modules
33  * to setup all of the sockets for the MPM to listen to and accept on.
34  */
35 struct ap_listen_rec {
36     /**
37      * The next listener in the list
38      */
39     ap_listen_rec *next;
40     /**
41      * The actual socket 
42      */
43     apr_socket_t *sd;
44     /**
45      * The sockaddr the socket should bind to
46      */
47     apr_sockaddr_t *bind_addr;
48     /**
49      * The accept function for this socket
50      */
51     accept_function accept_func;
52     /**
53      * Is this socket currently active 
54      */
55     int active;
56 /* more stuff here, like which protocol is bound to the port */
57 };
58
59 /**
60  * The global list of ap_listen_rec structures
61  */
62 AP_DECLARE_DATA extern ap_listen_rec *ap_listeners;
63
64 /**
65  * Setup all of the defaults for the listener list
66  */
67 void ap_listen_pre_config(void);
68 #if !defined(SPMT_OS2_MPM)
69 /**
70  * Loop through the global ap_listen_rec list and create all of the required
71  * sockets.  This executes the listen and bind on the sockets.
72  * @param s The global server_rec
73  * @return The number of open sockets.
74  * @warning This function is not available to Windows platforms, or the
75  * Prefork or SPMT_OS2 MPMs.
76  */ 
77 int ap_setup_listeners(server_rec *s);
78 #endif
79 /* Split into two #if's to make the exports scripts easier.
80  */
81 #if defined(SPMT_OS2_MPM)
82 /**
83  * Create and open a socket on the specified port.  This includes listening
84  * and binding the socket.
85  * @param process The process record for the currently running server
86  * @param port The port to open a socket on.
87  * @return The number of open sockets
88  * @warning This function is only available to Windows platforms, or the
89  * Prefork or SPMT_OS2 MPMs.
90  */
91 int ap_listen_open(process_rec *process, apr_port_t port);
92 #endif
93
94 /* Although these functions are exported from libmain, they are not really
95  * public functions.  These functions are actually called while parsing the
96  * config file, when one of the LISTEN_COMMANDS directives is read.  These
97  * should not ever be called by external modules.  ALL MPMs should include
98  * LISTEN_COMMANDS in their command_rec table so that these functions are
99  * called.
100  */ 
101 const char *ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg);
102 const char *ap_set_listener(cmd_parms *cmd, void *dummy, const char *ips);
103 const char *ap_set_send_buffer_size(cmd_parms *cmd, void *dummy,
104                                     const char *arg);
105 AP_DECLARE_NONSTD(const char *) ap_set_receive_buffer_size(cmd_parms *cmd,
106                                                            void *dummy,
107                                                            const char *arg);
108
109 #define LISTEN_COMMANDS \
110 AP_INIT_TAKE1("ListenBacklog", ap_set_listenbacklog, NULL, RSRC_CONF, \
111   "Maximum length of the queue of pending connections, as used by listen(2)"), \
112 AP_INIT_TAKE1("Listen", ap_set_listener, NULL, RSRC_CONF, \
113   "A port number or a numeric IP address and a port number"), \
114 AP_INIT_TAKE1("SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, \
115   "Send buffer size in bytes"), \
116 AP_INIT_TAKE1("ReceiveBufferSize", ap_set_receive_buffer_size, NULL, \
117               RSRC_CONF, "Receive buffer size in bytes")
118
119 #endif