Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
motorz.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 
17 #include "apr.h"
18 #include "apr_portable.h"
19 #include "apr_strings.h"
20 #include "apr_thread_proc.h"
21 #include "apr_signal.h"
22 
23 #define APR_WANT_STDIO
24 #define APR_WANT_STRFUNC
25 #include "apr_want.h"
26 
27 #if APR_HAVE_UNISTD_H
28 #include <unistd.h>
29 #endif
30 #if APR_HAVE_SYS_TYPES_H
31 #include <sys/types.h>
32 #endif
33 
34 #include "ap_config.h"
35 #include "httpd.h"
36 #include "mpm_default.h"
37 #include "http_main.h"
38 #include "http_log.h"
39 #include "http_config.h"
40 #include "http_core.h" /* for get_remote_host */
41 #include "http_connection.h"
42 #include "scoreboard.h"
43 #include "ap_mpm.h"
44 #include "util_mutex.h"
45 #include "unixd.h"
46 #include "http_vhost.h"
47 #include "mpm_common.h"
48 #include "ap_listen.h"
49 #include "ap_mmn.h"
50 #include "apr_poll.h"
51 #include "apr_skiplist.h"
52 #include "apr_thread_pool.h"
53 #include "util_time.h"
54 
55 #include <stdlib.h>
56 
57 #ifdef HAVE_TIME_H
58 #include <time.h>
59 #endif
60 #ifdef HAVE_SYS_PROCESSOR_H
61 #include <sys/processor.h> /* for bindprocessor() */
62 #endif
63 
64 #include <signal.h>
65 #include <sys/times.h>
66 
67 /* Limit on the total --- clients will be locked out if more servers than
68  * this are needed. It is intended solely to keep the server from crashing
69  * when things get out of hand.
70  *
71  * We keep a hard maximum number of servers, for two reasons --- first off,
72  * in case something goes seriously wrong, we want to stop the fork bomb
73  * short of actually crashing the machine we're running on by filling some
74  * kernel table. Secondly, it keeps the size of the scoreboard file small
75  * enough that we can read the whole thing without worrying too much about
76  * the overhead.
77  */
78 #ifndef DEFAULT_SERVER_LIMIT
79 #define DEFAULT_SERVER_LIMIT 256
80 #endif
81 
82 /* Admin can't tune ServerLimit beyond MAX_SERVER_LIMIT. We want
83  * some sort of compile-time limit to help catch typos.
84  */
85 #ifndef MAX_SERVER_LIMIT
86 #define MAX_SERVER_LIMIT 200000
87 #endif
88 
89 /* Limit on the threads per process. Clients will be locked out if more than
90  * this are needed.
91  *
92  * We keep this for one reason it keeps the size of the scoreboard file small
93  * enough that we can read the whole thing without worrying too much about
94  * the overhead.
95  */
96 #ifndef DEFAULT_THREAD_LIMIT
97 #define DEFAULT_THREAD_LIMIT 64
98 #endif
99 
100 /* Admin can't tune ThreadLimit beyond MAX_THREAD_LIMIT. We want
101  * some sort of compile-time limit to help catch typos.
102  */
103 #ifndef MAX_THREAD_LIMIT
104 #define MAX_THREAD_LIMIT 100000
105 #endif
106 
107 #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
108 
112 /* data retained by prefork across load/unload of the module
113  * allocated on first call to pre-config hook; located on
114  * subsequent calls to pre-config hook
115  */
119 
122  /*
123  * The max child slot ever assigned, preserved across restarts. Necessary
124  * to deal with MaxRequestWorkers changes across AP_SIG_GRACEFUL restarts. We
125  * use this value to optimize routines that have to scan the entire scoreboard.
126  */
133 };
134 
140 };
141 
142 typedef enum
143 {
148 
149 typedef struct motorz_sb_t motorz_sb_t;
151 {
153  void *baton;
154 };
155 
156 typedef void (*motorz_timer_cb) (motorz_core_t *mz, void *baton);
158  int flags, void *baton);
160  int flags, void *baton);
161 
162 
165 {
168  void *baton;
171 };
172 
175 {
193 };
apr_time_t expires
Definition: motorz.h:166
motorz_timer_cb cb
Definition: motorz.h:167
apr_proc_mutex_t * mutex
Definition: motorz.h:139
Apache Configuration.
motorz_core_t * mz
Definition: motorz.h:170
Definition: motorz.h:136
apr_pool_t * pool
Definition: motorz.h:169
Definition: apr_arch_thread_mutex.h:28
ap_listen_rec * listeners
Definition: motorz.h:138
ap_pod_t * pod
Definition: motorz.h:137
APR Thread Pool Library.
motorz_core_t * mz
Definition: motorz.h:177
int max_daemons_limit
Definition: motorz.h:127
struct apr_bucket_alloc_t apr_bucket_alloc_t
Definition: apr_buckets.h:123
motorz_poll_type_e type
Definition: motorz.h:152
Definition: motorz.h:146
Definition: motorz.h:164
Definition: apr_arch_proc_mutex.h:27
Apache Listeners Library.
apr_pollset_t * pollset
Definition: motorz.h:130
struct ap_sb_handle_t ap_sb_handle_t
Definition: scoreboard.h:164
Definition: motorz.h:150
APR Standard Headers Support.
motorz_poll_type_e
Definition: motorz.h:142
apr_bucket_alloc_t * ba
Definition: motorz.h:179
CORE HTTP Daemon.
Apache connection library.
Apache's listeners record.
Definition: ap_listen.h:47
apr_pool_t * pool
Definition: motorz.h:176
void(* motorz_io_file_cb)(motorz_core_t *mz, apr_socket_t *sock, int flags, void *baton)
Definition: motorz.h:159
void(* motorz_timer_cb)(motorz_core_t *mz, void *baton)
Definition: motorz.h:156
APR Poll interface.
struct apr_skiplist apr_skiplist
Definition: apr_skiplist.h:56
common stuff that unix MPMs will want
Structure to store things which are per connection.
Definition: httpd.h:1124
Virtual Host package.
Symbol export macros and hook functions.
APR Signal Handling.
Definition: motorz.h:117
int first_server_limit
Definition: motorz.h:120
Apache Logging library.
int maxclients_reported
Definition: motorz.h:121
apr_int64_t apr_time_t
Definition: apr_time.h:45
Command line options.
Definition: motorz.h:144
HTTP Daemon routines.
Definition: apr_poll.h:117
MotorZ MPM defaults.
A structure to contain connection state information.
Definition: httpd.h:1269
Definition: apr_arch_networkio.h:37
apr_pollfd_t pfd
Definition: motorz.h:188
request_rec * r
Definition: motorz.h:184
APR Platform Definitions.
ap_unixd_mpm_retained_data * mpm
Definition: motorz.h:118
Definition: motorz.h:145
apr_skiplist * timeout_ring
Definition: motorz.h:131
int suspended
Definition: motorz.h:186
apr_socket_t * sock
Definition: motorz.h:178
Apache date-time handling functions.
Definition: motorz.h:174
apr_thread_mutex_t * mtx
Definition: motorz.h:129
Apache Mutex support library.
APR Thread and Process Library.
A structure that represents the current request.
Definition: httpd.h:811
struct apr_thread_pool apr_thread_pool_t
Definition: apr_thread_pool.h:58
APR Strings library.
Apache scoreboard library.
Definition: mpm_common.h:240
Apache Multi-Processing Module library.
APR skip list implementation.
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
typedef void(APR_THREAD_FUNC *PFN_HSE_IO_COMPLETION)(EXTENSION_CONTROL_BLOCK *ecb
Module Magic Number.
conn_state_t cs
Definition: motorz.h:190
Definition: unixd.h:113
dav_resource int dav_locktoken dav_response int flags
Definition: mod_dav.h:1346
apr_pool_t * pool
Definition: motorz.h:128
apr_thread_pool_t * workers
Definition: motorz.h:132
motorz_timer_t timer
Definition: motorz.h:192
ap_sb_handle_t * sbh
Definition: motorz.h:180
Multi-Processing Modules functions.
conn_rec * c
Definition: motorz.h:182
APR Portability Routines.
void(* motorz_io_sock_cb)(motorz_core_t *mz, apr_socket_t *sock, int flags, void *baton)
Definition: motorz.h:157
void * baton
Definition: motorz.h:153
void * baton
Definition: motorz.h:168
Definition: apr_arch_poll_private.h:119