Apache HTTPD
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
33struct apr_pool_t;
36struct h2_bucket_beam;
37struct h2_config;
38struct h2_ihash_t;
39struct h2_stream;
40struct h2_request;
42struct h2_workers;
43struct h2_iqueue;
44
45#include <apr_queue.h>
46
47#include "h2_workers.h"
48
50
55
56typedef struct h2_mplx h2_mplx;
57
58struct 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
142int h2_mplx_c1_stream_is_running(h2_mplx *m, struct h2_stream *stream);
143
157 struct h2_session *session,
158 unsigned int *pstream_count);
159
168 struct h2_session *session);
169
170typedef void stream_ev_callback(void *ctx, struct h2_stream *stream);
171
179 void *on_ctx);
180
183
184typedef int h2_mplx_stream_cb(struct h2_stream *s, void *userdata);
185
193
198
205 struct h2_stream *stream);
206
210const 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.
apr_brigade_flush void * ctx
apr_size_t size
apr_uint32_t apr_uint32_t cmp
Definition apr_atomic.h:106
const char int apr_pool_t * pool
Definition apr_cstr.h:84
int apr_status_t
Definition apr_errno.h:44
const char * s
Definition apr_strings.h:95
const void * m
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
static struct h2_workers * workers
Definition h2_c1.c:48
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)
Definition h2_mplx.c:83
apr_status_t h2_mplx_c1_client_rst(h2_mplx *m, int stream_id, struct h2_stream *stream)
Definition h2_mplx.c:1122
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)
Definition h2_mplx.c:711
void h2_mplx_c1_going_keepalive(h2_mplx *m)
Definition h2_mplx.c:605
int h2_mplx_c1_shutdown(h2_mplx *m)
Definition h2_mplx.c:358
int h2_mplx_c1_stream_is_running(h2_mplx *m, struct h2_stream *stream)
Definition h2_mplx.c:118
void h2_mplx_c1_destroy(h2_mplx *m)
Definition h2_mplx.c:471
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)
Definition h2_mplx.c:643
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)
Definition h2_mplx.c:258
int h2_mplx_c1_all_streams_want_send_data(h2_mplx *m)
Definition h2_mplx.c:411
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)
Definition h2_mplx.c:614
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)
Definition h2_mplx.c:383
apr_status_t h2_mplx_c1_stream_cleanup(h2_mplx *m, struct h2_stream *stream, unsigned int *pstream_count)
Definition h2_mplx.c:549
const struct h2_stream * h2_mplx_c2_stream_get(h2_mplx *m, int stream_id)
Definition h2_mplx.c:562
static void on_stream_output(void *ctx, h2_stream *stream)
static void on_stream_input(void *ctx, h2_stream *stream)
static h2_stream * get_stream(h2_session *session, int stream_id)
Definition h2_session.c:79
Structure to store things which are per connection.
Definition httpd.h:1152
apr_pool_t * pool
Definition h2_mplx.h:52
apr_bucket_alloc_t * bucket_alloc
Definition h2_mplx.h:53
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
A structure to store information for each virtual server.
Definition httpd.h:1322
IN ULONG IN INT timeout