Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
h2_mplx.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 #ifndef __mod_h2__h2_mplx__
18 #define __mod_h2__h2_mplx__
19 
38 struct apr_pool_t;
39 struct apr_thread_mutex_t;
40 struct apr_thread_cond_t;
41 struct h2_bucket_beam;
42 struct h2_config;
43 struct h2_ihash_t;
44 struct h2_task;
45 struct h2_stream;
46 struct h2_request;
47 struct apr_thread_cond_t;
48 struct h2_workers;
49 struct h2_iqueue;
50 
51 #include <apr_queue.h>
52 
53 typedef struct h2_mplx h2_mplx;
54 
55 struct h2_mplx {
56  long id;
59  server_rec *s; /* server for master conn */
60 
61  unsigned int event_pending;
62  unsigned int aborted;
63  unsigned int is_registered; /* is registered at h2_workers */
64 
65  struct h2_ihash_t *streams; /* all streams currently processing */
66  struct h2_ihash_t *sredo; /* all streams that need to be re-started */
67  struct h2_ihash_t *shold; /* all streams done with task ongoing */
68  struct h2_ihash_t *spurge; /* all streams done, ready for destroy */
69 
70  struct h2_iqueue *q; /* all stream ids that need to be started */
71  struct h2_ififo *readyq; /* all stream ids ready for output */
72 
73  struct h2_ihash_t *redo_tasks; /* all tasks that need to be redone */
74 
75  int max_streams; /* max # of concurrent streams */
76  int max_stream_started; /* highest stream id that started processing */
77  int tasks_active; /* # of tasks being processed from this mplx */
78  int limit_active; /* current limit on active tasks, dynamic */
79  int max_active; /* max, hard limit # of active tasks in a process */
80  apr_time_t last_idle_block; /* last time, this mplx entered IDLE while
81  * streams were ready */
82  apr_time_t last_limit_change; /* last time, worker limit changed */
84 
88 
90 
92  apr_array_header_t *spare_slaves; /* spare slave connections */
93 
95 };
96 
97 
98 
99 /*******************************************************************************
100  * Object lifecycle and information.
101  ******************************************************************************/
102 
104 
110  struct h2_workers *workers);
111 
120 void h2_mplx_release_and_join(h2_mplx *m, struct apr_thread_cond_t *wait);
121 
122 apr_status_t h2_mplx_pop_task(h2_mplx *m, struct h2_task **ptask);
123 
124 void h2_mplx_task_done(h2_mplx *m, struct h2_task *task, struct h2_task **ptask);
125 
131 int h2_mplx_shutdown(h2_mplx *m);
132 
133 int h2_mplx_is_busy(h2_mplx *m);
134 
135 /*******************************************************************************
136  * IO lifetime of streams.
137  ******************************************************************************/
138 
139 struct h2_stream *h2_mplx_stream_get(h2_mplx *m, int id);
140 
149 
155  struct apr_thread_cond_t *iowait);
156 
158 
159 /*******************************************************************************
160  * Stream processing.
161  ******************************************************************************/
162 
172 apr_status_t h2_mplx_process(h2_mplx *m, struct h2_stream *stream,
173  h2_stream_pri_cmp *cmp, void *ctx);
174 
183 
184 typedef apr_status_t stream_ev_callback(void *ctx, struct h2_stream *stream);
185 
191 
199  stream_ev_callback *on_resume,
200  void *ctx);
201 
203 
204 typedef int h2_mplx_stream_cb(struct h2_stream *s, void *ctx);
205 
207 
208 /*******************************************************************************
209  * Output handling of streams.
210  ******************************************************************************/
211 
215 apr_status_t h2_mplx_out_open(h2_mplx *mplx, int stream_id,
216  struct h2_bucket_beam *beam);
217 
218 /*******************************************************************************
219  * h2_mplx list Manipulation.
220  ******************************************************************************/
221 
227 #define H2_MPLX_LIST_SENTINEL(b) APR_RING_SENTINEL((b), h2_mplx, link)
228 
234 #define H2_MPLX_LIST_EMPTY(b) APR_RING_EMPTY((b), h2_mplx, link)
235 
241 #define H2_MPLX_LIST_FIRST(b) APR_RING_FIRST(b)
242 
248 #define H2_MPLX_LIST_LAST(b) APR_RING_LAST(b)
249 
255 #define H2_MPLX_LIST_INSERT_HEAD(b, e) do { \
256 h2_mplx *ap__b = (e); \
257 APR_RING_INSERT_HEAD((b), ap__b, h2_mplx, link); \
258 } while (0)
259 
265 #define H2_MPLX_LIST_INSERT_TAIL(b, e) do { \
266 h2_mplx *ap__b = (e); \
267 APR_RING_INSERT_TAIL((b), ap__b, h2_mplx, link); \
268 } while (0)
269 
275 #define H2_MPLX_NEXT(e) APR_RING_NEXT((e), link)
276 
281 #define H2_MPLX_PREV(e) APR_RING_PREV((e), link)
282 
287 #define H2_MPLX_REMOVE(e) APR_RING_REMOVE((e), link)
288 
289 /*******************************************************************************
290  * h2_mplx DoS protection
291  ******************************************************************************/
292 
299 
300 #endif /* defined(__mod_h2__h2_mplx__) */
struct apr_thread_cond_t * join_wait
Definition: h2_mplx.h:87
int h2_mplx_shutdown(h2_mplx *m)
h2_mplx * h2_mplx_create(conn_rec *c, server_rec *s, apr_pool_t *master, struct h2_workers *workers)
size_t apr_size_t
Definition: apr.h:375
struct h2_ihash_t * spurge
Definition: h2_mplx.h:68
apr_array_header_t * spare_slaves
Definition: h2_mplx.h:92
apr_status_t stream_ev_callback(void *ctx, struct h2_stream *stream)
Definition: h2_mplx.h:184
apr_status_t h2_mplx_process(h2_mplx *m, struct h2_stream *stream, h2_stream_pri_cmp *cmp, void *ctx)
Definition: h2_task.h:52
Definition: h2_mplx.h:55
Definition: apr_arch_thread_mutex.h:28
Definition: apr_tables.h:62
apr_time_t last_idle_block
Definition: h2_mplx.h:80
server_rec * s
Definition: h2_workers.h:37
apr_pool_t * spare_io_pool
Definition: h2_mplx.h:91
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:552
apr_size_t stream_max_mem
Definition: h2_mplx.h:89
int max_stream_started
Definition: h2_mplx.h:76
unsigned int aborted
Definition: h2_mplx.h:62
Definition: h2.h:133
Thread Safe FIFO bounded queue.
Definition: h2_bucket_beam.h:164
void h2_mplx_task_done(h2_mplx *m, struct h2_task *task, struct h2_task **ptask)
struct h2_ififo h2_ififo
Definition: h2_util.h:267
struct h2_ihash_t * sredo
Definition: h2_mplx.h:66
apr_status_t h2_mplx_out_open(h2_mplx *mplx, int stream_id, struct h2_bucket_beam *beam)
apr_status_t h2_mplx_idle(h2_mplx *m)
apr_int64_t apr_interval_time_t
Definition: apr_time.h:55
int h2_mplx_awaits_data(h2_mplx *m)
struct h2_workers * workers
Definition: h2_mplx.h:94
apr_thread_mutex_t * lock
Definition: h2_mplx.h:85
Structure to store things which are per connection.
Definition: httpd.h:1124
struct h2_ihash_t * shold
Definition: h2_mplx.h:67
struct h2_stream * h2_mplx_stream_get(h2_mplx *m, int id)
apr_status_t h2_mplx_keep_active(h2_mplx *m, struct h2_stream *stream)
apr_status_t h2_mplx_reprioritize(h2_mplx *m, h2_stream_pri_cmp *cmp, void *ctx)
apr_int64_t apr_time_t
Definition: apr_time.h:45
apr_status_t h2_mplx_child_init(apr_pool_t *pool, server_rec *s)
apr_pool_t * pool
Definition: h2_mplx.h:58
unsigned int is_registered
Definition: h2_mplx.h:63
apr_status_t h2_mplx_dispatch_master_events(h2_mplx *m, stream_ev_callback *on_resume, void *ctx)
A structure to store information for each virtual server.
Definition: httpd.h:1311
apr_status_t h2_mplx_out_trywait(h2_mplx *m, apr_interval_time_t timeout, struct apr_thread_cond_t *iowait)
apr_status_t h2_mplx_stream_do(h2_mplx *m, h2_mplx_stream_cb *cb, void *ctx)
int tasks_active
Definition: h2_mplx.h:77
apr_status_t h2_mplx_pop_task(h2_mplx *m, struct h2_task **ptask)
int max_active
Definition: h2_mplx.h:79
struct h2_ihash_t h2_ihash_t
Definition: h2_util.h:42
Definition: h2_stream.h:65
struct apr_thread_cond_t * added_output
Definition: h2_mplx.h:86
apr_status_t h2_mplx_stream_cleanup(h2_mplx *m, struct h2_stream *stream)
int limit_active
Definition: h2_mplx.h:78
unsigned int event_pending
Definition: h2_mplx.h:61
int h2_stream_pri_cmp(int stream_id1, int stream_id2, void *ctx)
Definition: h2.h:157
struct h2_iqueue * q
Definition: h2_mplx.h:70
struct h2_ihash_t * redo_tasks
Definition: h2_mplx.h:73
apr_interval_time_t limit_change_interval
Definition: h2_mplx.h:83
struct h2_ihash_t * streams
Definition: h2_mplx.h:65
conn_rec * c
Definition: h2_mplx.h:57
long id
Definition: h2_mplx.h:56
struct h2_ififo * readyq
Definition: h2_mplx.h:71
Definition: h2_util.h:76
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
int apr_status_t
Definition: apr_errno.h:44
int h2_mplx_stream_cb(struct h2_stream *s, void *ctx)
Definition: h2_mplx.h:204
int h2_mplx_is_busy(h2_mplx *m)
int h2_mplx_has_master_events(h2_mplx *m)
int max_streams
Definition: h2_mplx.h:75
Definition: apr_arch_thread_cond.h:34
Definition: h2_workers.h:36
apr_time_t last_limit_change
Definition: h2_mplx.h:82
void h2_mplx_release_and_join(h2_mplx *m, struct apr_thread_cond_t *wait)
server_rec * s
Definition: h2_mplx.h:59