Apache2
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 
33 struct apr_pool_t;
34 struct apr_thread_mutex_t;
35 struct apr_thread_cond_t;
36 struct h2_bucket_beam;
37 struct h2_config;
38 struct h2_ihash_t;
39 struct h2_stream;
40 struct h2_request;
41 struct apr_thread_cond_t;
42 struct h2_workers;
43 struct h2_iqueue;
44 
45 #include <apr_queue.h>
46 
47 #include "h2_workers.h"
48 
49 typedef struct h2_c2_transit h2_c2_transit;
50 
51 struct h2_c2_transit {
54 };
55 
56 typedef struct h2_mplx h2_mplx;
57 
58 struct h2_mplx {
59  int child_num; /* child this runs in */
60  apr_uint32_t id; /* id unique per child */
61  conn_rec *c1; /* the main connection */
63  struct h2_stream *stream0; /* HTTP/2's stream 0 */
64  server_rec *s; /* server for master conn */
65 
66  int shutdown; /* we are shutting down */
67  int aborted; /* we need to get out of here asap */
68  int polling; /* is waiting/processing pollset events */
69  ap_conn_producer_t *producer; /* registered producer at h2_workers */
70 
71  struct h2_ihash_t *streams; /* all streams active */
72  struct h2_ihash_t *shold; /* all streams done with c2 processing ongoing */
73  apr_array_header_t *spurge; /* all streams done, ready for destroy */
74 
75  struct h2_iqueue *q; /* all stream ids that need to be started */
76 
77  apr_size_t stream_max_mem; /* max memory to buffer for a stream */
78  apr_uint32_t max_streams; /* max # of concurrent streams */
79  apr_uint32_t max_stream_id_started; /* highest stream id that started processing */
80 
81  apr_uint32_t processing_count; /* # of c2 working for this mplx */
82  apr_uint32_t processing_limit; /* current limit on processing c2s, dynamic */
83  apr_uint32_t processing_max; /* max, hard limit of processing c2s */
84 
85  apr_time_t last_mood_change; /* last time, processing limit changed */
86  apr_interval_time_t mood_update_interval; /* how frequent we update at most */
87  apr_uint32_t irritations_since; /* irritations (>0) or happy events (<0) since last mood change */
88 
91 
92  apr_pollset_t *pollset; /* pollset for c1/c2 IO events */
95 
96  apr_thread_mutex_t *poll_lock; /* protect modifications of queues below */
97  struct h2_iqueue *streams_input_read; /* streams whose input has been read from */
98  struct h2_iqueue *streams_output_written; /* streams whose output has been written to */
99 
100  struct h2_workers *workers; /* h2 workers process wide instance */
101 
102  apr_uint32_t max_spare_transits; /* max number of transit pools idling */
103  apr_array_header_t *c2_transits; /* base pools for running c2 connections */
104 };
105 
107 
113  struct h2_stream *stream0,
114  server_rec *s, apr_pool_t *master,
115  struct h2_workers *workers);
116 
123 
130 
140  unsigned int *pstream_count);
141 
143 
154  struct h2_iqueue *read_to_process,
155  h2_stream_get_fn *get_stream,
157  struct h2_session *session,
158  unsigned int *pstream_count);
159 
168  struct h2_session *session);
169 
170 typedef void stream_ev_callback(void *ctx, struct h2_stream *stream);
171 
177  stream_ev_callback *on_stream_input,
178  stream_ev_callback *on_stream_output,
179  void *on_ctx);
180 
183 
184 typedef int h2_mplx_stream_cb(struct h2_stream *s, void *userdata);
185 
193 
198 
205  struct h2_stream *stream);
206 
210 const struct h2_stream *h2_mplx_c2_stream_get(h2_mplx *m, int stream_id);
211 
218 
219 
226 
227 #define H2_MPLX_MSG(m, msg) \
228  "h2_mplx(%d-%lu): "msg, m->child_num, (unsigned long)m->id
229 
230 #endif /* defined(__mod_h2__h2_mplx__) */
Thread Safe FIFO bounded queue.
struct apr_bucket_alloc_t apr_bucket_alloc_t
Definition: apr_buckets.h:128
const char * s
Definition: mod_dav.h:1327
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:557
int apr_status_t
Definition: apr_errno.h:44
unsigned int apr_uint32_t
Definition: apr.h:348
size_t apr_size_t
Definition: apr.h:394
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
apr_int64_t apr_interval_time_t
Definition: apr_time.h:55
apr_int64_t apr_time_t
Definition: apr_time.h:45
struct h2_stream * h2_stream_get_fn(struct h2_session *session, int stream_id)
Definition: h2.h:195
int h2_stream_pri_cmp_fn(int stream_id1, int stream_id2, void *session)
Definition: h2.h:194
void stream_ev_callback(void *ctx, struct h2_stream *stream)
Definition: h2_mplx.h:170
apr_status_t h2_mplx_c1_child_init(apr_pool_t *pool, server_rec *s)
apr_status_t h2_mplx_c1_client_rst(h2_mplx *m, int stream_id, struct h2_stream *stream)
apr_status_t h2_mplx_worker_pop_c2(h2_mplx *m, conn_rec **out_c2)
void h2_mplx_c2_output_written(h2_mplx *m, conn_rec *c2)
void h2_mplx_c1_process(h2_mplx *m, struct h2_iqueue *read_to_process, h2_stream_get_fn *get_stream, h2_stream_pri_cmp_fn *cmp, struct h2_session *session, unsigned int *pstream_count)
h2_mplx * h2_mplx_c1_create(int child_id, apr_uint32_t id, struct h2_stream *stream0, server_rec *s, apr_pool_t *master, struct h2_workers *workers)
void h2_mplx_c1_going_keepalive(h2_mplx *m)
int h2_mplx_c1_shutdown(h2_mplx *m)
int h2_mplx_c1_stream_is_running(h2_mplx *m, struct h2_stream *stream)
void h2_mplx_c1_destroy(h2_mplx *m)
int h2_mplx_stream_cb(struct h2_stream *s, void *userdata)
Definition: h2_mplx.h:184
apr_status_t h2_mplx_c1_reprioritize(h2_mplx *m, h2_stream_pri_cmp_fn *cmp, struct h2_session *session)
const struct h2_stream * h2_mplx_c2_stream_get(h2_mplx *m, int stream_id)
int h2_mplx_c1_all_streams_want_send_data(h2_mplx *m)
apr_status_t h2_mplx_c1_poll(h2_mplx *m, apr_interval_time_t timeout, stream_ev_callback *on_stream_input, stream_ev_callback *on_stream_output, void *on_ctx)
void h2_mplx_c2_input_read(h2_mplx *m, conn_rec *c2)
apr_status_t h2_mplx_c1_streams_do(h2_mplx *m, h2_mplx_stream_cb *cb, void *ctx)
apr_status_t h2_mplx_c1_stream_cleanup(h2_mplx *m, struct h2_stream *stream, unsigned int *pstream_count)
struct h2_ihash_t h2_ihash_t
Definition: h2_util.h:42
struct ap_conn_producer_t ap_conn_producer_t
Definition: h2_workers.h:70
struct h2_workers h2_workers
Definition: h2_workers.h:31
Definition: apr_tables.h:62
Definition: apr_arch_poll_private.h:124
Definition: apr_arch_thread_cond.h:34
Definition: apr_arch_thread_mutex.h:28
Structure to store things which are per connection.
Definition: httpd.h:1193
Definition: h2_bucket_beam.h:44
Definition: h2_mplx.h:51
apr_pool_t * pool
Definition: h2_mplx.h:52
apr_bucket_alloc_t * bucket_alloc
Definition: h2_mplx.h:53
Definition: h2_util.h:76
Definition: h2_mplx.h:58
apr_pollset_t * pollset
Definition: h2_mplx.h:92
int child_num
Definition: h2_mplx.h:59
apr_uint32_t processing_limit
Definition: h2_mplx.h:82
apr_uint32_t processing_max
Definition: h2_mplx.h:83
apr_thread_mutex_t * lock
Definition: h2_mplx.h:89
apr_uint32_t processing_count
Definition: h2_mplx.h:81
server_rec * s
Definition: h2_mplx.h:64
int aborted
Definition: h2_mplx.h:67
struct h2_iqueue * streams_input_read
Definition: h2_mplx.h:97
apr_interval_time_t mood_update_interval
Definition: h2_mplx.h:86
int shutdown
Definition: h2_mplx.h:66
struct h2_ihash_t * shold
Definition: h2_mplx.h:72
struct h2_stream * stream0
Definition: h2_mplx.h:63
struct h2_workers * workers
Definition: h2_mplx.h:100
apr_uint32_t id
Definition: h2_mplx.h:60
apr_uint32_t max_spare_transits
Definition: h2_mplx.h:102
apr_array_header_t * c2_transits
Definition: h2_mplx.h:103
struct h2_iqueue * streams_output_written
Definition: h2_mplx.h:98
struct apr_thread_cond_t * join_wait
Definition: h2_mplx.h:90
apr_size_t stream_max_mem
Definition: h2_mplx.h:77
apr_array_header_t * streams_ev_out
Definition: h2_mplx.h:94
apr_pool_t * pool
Definition: h2_mplx.h:62
apr_uint32_t max_streams
Definition: h2_mplx.h:78
apr_array_header_t * streams_ev_in
Definition: h2_mplx.h:93
struct h2_ihash_t * streams
Definition: h2_mplx.h:71
conn_rec * c1
Definition: h2_mplx.h:61
ap_conn_producer_t * producer
Definition: h2_mplx.h:69
apr_time_t last_mood_change
Definition: h2_mplx.h:85
apr_array_header_t * spurge
Definition: h2_mplx.h:73
struct h2_iqueue * q
Definition: h2_mplx.h:75
apr_uint32_t irritations_since
Definition: h2_mplx.h:87
int polling
Definition: h2_mplx.h:68
apr_thread_mutex_t * poll_lock
Definition: h2_mplx.h:96
apr_uint32_t max_stream_id_started
Definition: h2_mplx.h:79
Definition: h2.h:169
Definition: h2_session.h:64
Definition: h2_stream.h:78
A structure to store information for each virtual server.
Definition: httpd.h:1382