]> granicus.if.org Git - apache/blob - server/mpm/simple/simple_types.h
Remove MPM-private stuff from conn_state_t
[apache] / server / mpm / simple / simple_types.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 #include "apr.h"
18 #include "apr_pools.h"
19 #include "apr_poll.h"
20 #include "apr_hash.h"
21 #include "apr_ring.h"
22 #include "apr_thread_pool.h"
23 #include "apr_buckets.h"
24 #include "httpd.h"
25
26 #ifndef APACHE_MPM_SIMPLE_TYPES_H
27 #define APACHE_MPM_SIMPLE_TYPES_H
28
29 typedef struct simple_core_t simple_core_t;
30
31 typedef struct
32 {
33     int proc_count;
34     int thread_count;
35     int max_requests_per_child;
36 } simple_proc_mgr_t;
37
38 #define SIMPLE_MAX_PROC (500000)
39 #define SIMPLE_DEF_PROC (5)
40 #define SIMPLE_MIN_PROC (1)
41 #define SIMPLE_MAX_THREADS (500000)
42 #define SIMPLE_DEF_THREADS (5)
43 #define SIMPLE_MIN_THREADS (1)
44
45 typedef void (*simple_timer_cb) (simple_core_t * sc, void *baton);
46 typedef void (*simple_io_sock_cb) (simple_core_t * sc, apr_socket_t * sock,
47                                    int flags, void *baton);
48 typedef void (*simple_io_file_cb) (simple_core_t * sc, apr_socket_t * sock,
49                                    int flags, void *baton);
50
51 typedef struct simple_sb_t simple_sb_t;
52
53 typedef enum
54 {
55     SIMPLE_PT_CORE_ACCEPT,
56     SIMPLE_PT_CORE_IO,
57     /* pqXXXXXX: User IO not defined yet. */
58     SIMPLE_PT_USER
59 } simple_poll_type_e;
60
61 typedef enum
62 {
63     SIMPLE_SPAWN_FORK,
64     SIMPLE_SPAWN_EXEC,
65 } simple_spawn_type_e;
66
67 struct simple_sb_t
68 {
69     simple_poll_type_e type;
70     void *baton;
71 };
72
73 typedef struct simple_timer_t simple_timer_t;
74 struct simple_timer_t
75 {
76     APR_RING_ENTRY(simple_timer_t) link;
77     apr_time_t expires;
78     simple_timer_cb cb;
79     void *baton;
80     apr_pool_t *pool;
81     simple_core_t *sc;
82 };
83
84 typedef struct simple_child_t simple_child_t;
85 struct simple_child_t
86 {
87     /* TODO: More is needed here. */
88     pid_t pid;
89 };
90
91 struct simple_core_t
92 {
93     apr_pool_t *pool;
94     apr_thread_mutex_t *mtx;
95
96     int mpm_state;
97     int restart_num;
98
99     int run_single_process;
100     int run_foreground;
101     simple_spawn_type_e spawn_via;
102
103     simple_proc_mgr_t procmgr;
104
105     /* PID -> simple_child_t map */
106     apr_hash_t *children;
107
108     apr_pollcb_t *pollcb;
109
110     /* List of upcoming timers, sorted by nearest first.
111      */
112     APR_RING_HEAD(simple_timer_ring_t, simple_timer_t) timer_ring;
113
114     apr_thread_pool_t *workers;
115 };
116
117 typedef struct simple_conn_t simple_conn_t;
118 struct simple_conn_t
119 {
120     apr_pool_t *pool;
121     simple_core_t *sc;
122     apr_socket_t *sock;
123     apr_bucket_alloc_t *ba;
124     conn_rec *c;
125     /** poll file descriptor information */
126     apr_pollfd_t pfd;
127     /** public parts of the connection state */
128     conn_state_t cs;
129 };
130
131 simple_core_t *simple_core_get(void);
132
133 /* Allocates/initializes data retained over the life of the process */
134 apr_status_t simple_core_init_once(void);
135
136 #endif /* APACHE_MPM_SIMPLE_TYPES_H */