Apache2
h2_session.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_session__
18 #define __mod_h2__h2_session__
19 
20 #include "h2_c1_io.h"
21 
31 #include "h2.h"
32 
33 struct apr_thread_mutext_t;
34 struct apr_thread_cond_t;
35 struct h2_ctx;
36 struct h2_config;
37 struct h2_ihash_t;
38 struct h2_mplx;
39 struct h2_priority;
40 struct h2_push;
41 struct h2_push_diary;
42 struct h2_session;
43 struct h2_stream;
44 struct h2_stream_monitor;
45 struct h2_workers;
46 
47 struct nghttp2_session;
48 
49 typedef enum {
50  H2_SESSION_EV_INIT, /* session was initialized */
51  H2_SESSION_EV_INPUT_PENDING, /* c1 input may have data pending */
52  H2_SESSION_EV_INPUT_EXHAUSTED, /* c1 input exhausted */
53  H2_SESSION_EV_LOCAL_GOAWAY, /* we send a GOAWAY */
54  H2_SESSION_EV_REMOTE_GOAWAY, /* remote send us a GOAWAY */
55  H2_SESSION_EV_CONN_ERROR, /* connection error */
56  H2_SESSION_EV_PROTO_ERROR, /* protocol error */
57  H2_SESSION_EV_CONN_TIMEOUT, /* connection timeout */
58  H2_SESSION_EV_NGH2_DONE, /* nghttp2 wants neither read nor write anything */
59  H2_SESSION_EV_MPM_STOPPING, /* the process is stopping */
60  H2_SESSION_EV_PRE_CLOSE, /* connection will close after this */
61  H2_SESSION_EV_NO_MORE_STREAMS, /* no more streams to process */
63 
64 typedef struct h2_session {
65  int child_num; /* child number this session runs in */
66  apr_uint32_t id; /* identifier of this session, unique per child */
67  conn_rec *c1; /* the main connection this session serves */
68  request_rec *r; /* the request that started this in case
69  * of 'h2c', NULL otherwise */
70  server_rec *s; /* server/vhost we're starting on */
71  apr_pool_t *pool; /* pool to use in session */
72  struct h2_mplx *mplx; /* multiplexer for stream data */
73  struct h2_workers *workers; /* for executing streams */
74  struct h2_c1_io_in_ctx_t *cin; /* connection input filter context */
75  h2_c1_io io; /* io on httpd conn filters */
76  unsigned int padding_max; /* max number of padding bytes */
77  int padding_always; /* padding has precedence over I/O optimizations */
78  struct nghttp2_session *ngh2; /* the nghttp2 session (internal use) */
79 
80  h2_session_state state; /* state session is in */
81 
82  h2_session_props local; /* properties of local session */
83  h2_session_props remote; /* properites of remote session */
84 
85  unsigned int reprioritize : 1; /* scheduled streams priority changed */
86  unsigned int flush : 1; /* flushing output necessary */
87  apr_interval_time_t wait_us; /* timeout during BUSY_WAIT state, micro secs */
88 
89  struct h2_push_diary *push_diary; /* remember pushes, avoid duplicates */
90 
91  struct h2_stream_monitor *monitor;/* monitor callbacks for streams */
92  unsigned int open_streams; /* number of streams processing */
93 
94  unsigned int streams_done; /* number of http/2 streams handled */
95  unsigned int responses_submitted; /* number of http/2 responses submitted */
96  unsigned int streams_reset; /* number of http/2 streams reset by client */
97  unsigned int pushes_promised; /* number of http/2 push promises submitted */
98  unsigned int pushes_submitted; /* number of http/2 pushed responses submitted */
99  unsigned int pushes_reset; /* number of http/2 pushed reset by client */
100 
101  apr_size_t frames_received; /* number of http/2 frames received */
102  apr_size_t frames_sent; /* number of http/2 frames sent */
103 
104  apr_size_t max_stream_count; /* max number of open streams */
105  apr_size_t max_stream_mem; /* max buffer memory for a single stream */
106  apr_size_t max_data_frame_len; /* max amount of bytes for a single DATA frame */
107 
108  apr_size_t idle_frames; /* number of rcvd frames that kept session in idle state */
109  apr_interval_time_t idle_delay; /* Time we delay processing rcvd frames in idle state */
110 
111  apr_bucket_brigade *bbtmp; /* brigade for keeping temporary data */
112 
113  char status[64]; /* status message for scoreboard */
114  int last_status_code; /* the one already reported */
115  const char *last_status_msg; /* the one already reported */
116 
117  int input_flushed; /* stream input was flushed */
118  struct h2_iqueue *out_c1_blocked; /* all streams with output blocked on c1 buffer full */
119  struct h2_iqueue *ready_to_process; /* all streams ready for processing */
120 
122 
124 
136  conn_rec *c, request_rec *r, server_rec *,
137  struct h2_workers *workers);
138 
140  int err, const char *msg);
141 
149 
154 
161 void h2_session_abort(h2_session *session, apr_status_t reason);
162 
168 
179  struct h2_stream *is, struct h2_push *push);
180 
182  struct h2_stream *stream,
183  const struct h2_priority *prio);
184 
193  int arg, const char *msg);
194 
195 
196 #define H2_SSSN_MSG(s, msg) \
197  "h2_session(%d-%lu,%s,%d): "msg, s->child_num, (unsigned long)s->id, \
198  h2_session_state_str(s->state), \
199  s->open_streams
200 
201 #define H2_SSSN_LOG(aplogno, s, msg) aplogno H2_SSSN_MSG(s, msg)
202 
203 #define H2_SSSN_STRM_MSG(s, stream_id, msg) \
204  "h2_stream(%d-%lu-%d): "msg, s->child_num, (unsigned long)s->id, stream_id
205 
206 #endif /* defined(__mod_h2__h2_session__) */
request_rec * r
Definition: mod_dav.h:518
dav_error * err
Definition: mod_dav.h:203
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
h2_session_state
Definition: h2.h:121
int h2_session_push_enabled(h2_session *session)
void h2_session_event(h2_session *session, h2_session_event_t ev, int err, const char *msg)
apr_status_t h2_session_pre_close(h2_session *session, int async)
h2_session_event_t
Definition: h2_session.h:49
@ H2_SESSION_EV_PRE_CLOSE
Definition: h2_session.h:60
@ H2_SESSION_EV_NGH2_DONE
Definition: h2_session.h:58
@ H2_SESSION_EV_INIT
Definition: h2_session.h:50
@ H2_SESSION_EV_PROTO_ERROR
Definition: h2_session.h:56
@ H2_SESSION_EV_INPUT_EXHAUSTED
Definition: h2_session.h:52
@ H2_SESSION_EV_INPUT_PENDING
Definition: h2_session.h:51
@ H2_SESSION_EV_MPM_STOPPING
Definition: h2_session.h:59
@ H2_SESSION_EV_CONN_TIMEOUT
Definition: h2_session.h:57
@ H2_SESSION_EV_LOCAL_GOAWAY
Definition: h2_session.h:53
@ H2_SESSION_EV_CONN_ERROR
Definition: h2_session.h:55
@ H2_SESSION_EV_NO_MORE_STREAMS
Definition: h2_session.h:61
@ H2_SESSION_EV_REMOTE_GOAWAY
Definition: h2_session.h:54
struct h2_session h2_session
void h2_session_dispatch_event(h2_session *session, h2_session_event_t ev, int arg, const char *msg)
apr_status_t h2_session_process(h2_session *session, int async)
apr_status_t h2_session_create(h2_session **psession, conn_rec *c, request_rec *r, server_rec *, struct h2_workers *workers)
const char * h2_session_state_str(h2_session_state state)
struct h2_stream * h2_session_push(h2_session *session, struct h2_stream *is, struct h2_push *push)
void h2_session_abort(h2_session *session, apr_status_t reason)
apr_status_t h2_session_set_prio(h2_session *session, struct h2_stream *stream, const struct h2_priority *prio)
struct h2_ihash_t h2_ihash_t
Definition: h2_util.h:42
struct h2_workers h2_workers
Definition: h2_workers.h:31
Definition: apr_buckets.h:263
Definition: apr_arch_thread_cond.h:34
Structure to store things which are per connection.
Definition: httpd.h:1193
Definition: h2_c1_io.h:29
Definition: h2_util.h:76
Definition: h2_mplx.h:58
Definition: h2.h:109
Definition: h2_push.h:82
Definition: h2_push.h:30
Definition: h2.h:130
Definition: h2_session.h:64
apr_bucket_brigade * bbtmp
Definition: h2_session.h:111
unsigned int pushes_submitted
Definition: h2_session.h:98
unsigned int responses_submitted
Definition: h2_session.h:95
struct h2_workers * workers
Definition: h2_session.h:73
struct h2_push_diary * push_diary
Definition: h2_session.h:89
apr_uint32_t id
Definition: h2_session.h:66
unsigned int reprioritize
Definition: h2_session.h:85
apr_interval_time_t wait_us
Definition: h2_session.h:87
struct h2_iqueue * out_c1_blocked
Definition: h2_session.h:118
apr_size_t idle_frames
Definition: h2_session.h:108
unsigned int padding_max
Definition: h2_session.h:76
apr_size_t frames_received
Definition: h2_session.h:101
h2_c1_io io
Definition: h2_session.h:75
unsigned int streams_done
Definition: h2_session.h:94
int child_num
Definition: h2_session.h:65
apr_size_t frames_sent
Definition: h2_session.h:102
apr_size_t max_data_frame_len
Definition: h2_session.h:106
struct h2_c1_io_in_ctx_t * cin
Definition: h2_session.h:74
apr_size_t max_stream_count
Definition: h2_session.h:104
struct h2_mplx * mplx
Definition: h2_session.h:72
h2_session_props remote
Definition: h2_session.h:83
unsigned int pushes_promised
Definition: h2_session.h:97
int last_status_code
Definition: h2_session.h:114
unsigned int flush
Definition: h2_session.h:86
conn_rec * c1
Definition: h2_session.h:67
unsigned int open_streams
Definition: h2_session.h:92
struct h2_stream_monitor * monitor
Definition: h2_session.h:91
char status[64]
Definition: h2_session.h:113
const char * last_status_msg
Definition: h2_session.h:115
struct h2_iqueue * ready_to_process
Definition: h2_session.h:119
request_rec * r
Definition: h2_session.h:68
h2_session_state state
Definition: h2_session.h:80
apr_size_t max_stream_mem
Definition: h2_session.h:105
h2_session_props local
Definition: h2_session.h:82
int input_flushed
Definition: h2_session.h:117
unsigned int pushes_reset
Definition: h2_session.h:99
apr_interval_time_t idle_delay
Definition: h2_session.h:109
server_rec * s
Definition: h2_session.h:70
struct nghttp2_session * ngh2
Definition: h2_session.h:78
int padding_always
Definition: h2_session.h:77
unsigned int streams_reset
Definition: h2_session.h:96
apr_pool_t * pool
Definition: h2_session.h:71
Definition: h2_stream.h:55
Definition: h2_stream.h:78
struct h2_session * session
Definition: h2_stream.h:85
A structure that represents the current request.
Definition: httpd.h:856
A structure to store information for each virtual server.
Definition: httpd.h:1382