Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
h2_session.h
Go to the documentation of this file.
1 /* Copyright 2015 greenbytes GmbH (https://www.greenbytes.de)
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8 
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __mod_h2__h2_session__
17 #define __mod_h2__h2_session__
18 
19 #include "h2_conn_io.h"
20 
40 #include "h2.h"
41 
42 struct apr_thread_mutext_t;
43 struct apr_thread_cond_t;
44 struct h2_ctx;
45 struct h2_config;
46 struct h2_filter_cin;
47 struct h2_ihash_t;
48 struct h2_mplx;
49 struct h2_priority;
50 struct h2_push;
51 struct h2_push_diary;
52 struct h2_session;
53 struct h2_stream;
54 struct h2_task;
55 struct h2_workers;
56 
57 struct nghttp2_session;
58 
59 typedef enum {
60  H2_SESSION_EV_INIT, /* session was initialized */
61  H2_SESSION_EV_LOCAL_GOAWAY, /* we send a GOAWAY */
62  H2_SESSION_EV_REMOTE_GOAWAY, /* remote send us a GOAWAY */
63  H2_SESSION_EV_CONN_ERROR, /* connection error */
64  H2_SESSION_EV_PROTO_ERROR, /* protocol error */
65  H2_SESSION_EV_CONN_TIMEOUT, /* connection timeout */
66  H2_SESSION_EV_NO_IO, /* nothing has been read or written */
67  H2_SESSION_EV_STREAM_READY, /* stream signalled availability of headers/data */
68  H2_SESSION_EV_DATA_READ, /* connection data has been read */
69  H2_SESSION_EV_NGH2_DONE, /* nghttp2 wants neither read nor write anything */
70  H2_SESSION_EV_MPM_STOPPING, /* the process is stopping */
71  H2_SESSION_EV_PRE_CLOSE, /* connection will close after this */
72  H2_SESSION_EV_STREAM_OPEN, /* stream has been opened */
73  H2_SESSION_EV_STREAM_DONE, /* stream has been handled completely */
75 
76 typedef struct h2_session {
77  long id; /* identifier of this session, unique
78  * inside a httpd process */
79  conn_rec *c; /* the connection this session serves */
80  request_rec *r; /* the request that started this in case
81  * of 'h2c', NULL otherwise */
82  server_rec *s; /* server/vhost we're starting on */
83  const struct h2_config *config; /* Relevant config for this session */
84  apr_pool_t *pool; /* pool to use in session */
85  struct h2_mplx *mplx; /* multiplexer for stream data */
86  struct h2_workers *workers; /* for executing stream tasks */
87  struct h2_filter_cin *cin; /* connection input filter context */
88  h2_conn_io io; /* io on httpd conn filters */
89  struct nghttp2_session *ngh2; /* the nghttp2 session (internal use) */
90 
91  h2_session_state state; /* state session is in */
92 
93  h2_session_props local; /* properties of local session */
94  h2_session_props remote; /* properites of remote session */
95 
96  unsigned int reprioritize : 1; /* scheduled streams priority changed */
97  unsigned int eoc_written : 1; /* h2 eoc bucket written */
98  unsigned int flush : 1; /* flushing output necessary */
99  unsigned int have_read : 1; /* session has read client data */
100  unsigned int have_written : 1; /* session did write data to client */
101  apr_interval_time_t wait_us; /* timeout during BUSY_WAIT state, micro secs */
102 
103  struct h2_push_diary *push_diary; /* remember pushes, avoid duplicates */
104 
105  int open_streams; /* number of streams open */
106  int unsent_submits; /* number of submitted, but not yet written responses. */
107  int unsent_promises; /* number of submitted, but not yet written push promised */
108 
109  int responses_submitted; /* number of http/2 responses submitted */
110  int streams_reset; /* number of http/2 streams reset by client */
111  int pushes_promised; /* number of http/2 push promises submitted */
112  int pushes_submitted; /* number of http/2 pushed responses submitted */
113  int pushes_reset; /* number of http/2 pushed reset by client */
114 
115  apr_size_t frames_received; /* number of http/2 frames received */
116  apr_size_t frames_sent; /* number of http/2 frames sent */
117 
118  apr_size_t max_stream_count; /* max number of open streams */
119  apr_size_t max_stream_mem; /* max buffer memory for a single stream */
120 
121  apr_time_t idle_until; /* Time we shut down due to sheer boredom */
122  apr_time_t keep_sync_until; /* Time we sync wait until passing to async mpm */
123 
124  apr_bucket_brigade *bbtmp; /* brigade for keeping temporary data */
125  struct apr_thread_cond_t *iowait; /* our cond when trywaiting for data */
126 
127  char status[64]; /* status message for scoreboard */
128  int last_status_code; /* the one already reported */
129  const char *last_status_msg; /* the one already reported */
130 } h2_session;
131 
132 
141 h2_session *h2_session_create(conn_rec *c, struct h2_ctx *ctx,
142  struct h2_workers *workers);
143 
153  struct h2_workers *workers);
154 
161 apr_status_t h2_session_process(h2_session *session, int async);
162 
166 apr_status_t h2_session_pre_close(h2_session *session, int async);
167 
173 void h2_session_eoc_callback(h2_session *session);
174 
181 void h2_session_abort(h2_session *session, apr_status_t reason);
182 
186 void h2_session_close(h2_session *session);
187 
197 struct h2_stream *h2_session_open_stream(h2_session *session, int stream_id,
198  int initiated_on,
199  const h2_request *req);
200 
201 
207 
214  struct h2_stream *stream);
215 
226  struct h2_stream *is, struct h2_push *push);
227 
229  struct h2_stream *stream,
230  const struct h2_priority *prio);
231 
232 
233 #endif /* defined(__mod_h2__h2_session__) */
int unsent_submits
Definition: h2_session.h:106
int pushes_submitted
Definition: h2_session.h:112
size_t apr_size_t
Definition: apr.h:375
struct nghttp2_session * ngh2
Definition: h2_session.h:89
apr_size_t max_stream_mem
Definition: h2_session.h:119
Definition: h2_session.h:63
apr_size_t max_stream_count
Definition: h2_session.h:118
Definition: h2_task.h:52
char status[64]
Definition: h2_session.h:127
struct h2_session * session
Definition: h2_stream.h:49
Definition: h2_mplx.h:62
struct h2_filter_cin * cin
Definition: h2_session.h:87
request_rec * r
Definition: h2_session.h:80
Definition: h2_session.h:61
int pushes_reset
Definition: h2_session.h:113
Definition: h2_session.h:64
apr_size_t frames_received
Definition: h2_session.h:115
apr_interval_time_t wait_us
Definition: h2_session.h:101
Definition: h2.h:71
Definition: h2_session.h:65
struct h2_push_diary * push_diary
Definition: h2_session.h:103
Definition: h2.h:118
Definition: h2_push.h:26
apr_status_t h2_session_process(h2_session *session, int async)
h2_session_state state
Definition: h2_session.h:91
apr_bucket_brigade * bbtmp
Definition: h2_session.h:124
Definition: h2_conn_io.h:28
Definition: h2_session.h:73
Definition: h2_session.h:62
Definition: h2_session.h:71
Definition: apr_buckets.h:258
Definition: h2_config.h:57
apr_int64_t apr_interval_time_t
Definition: apr_time.h:55
apr_status_t h2_session_set_prio(h2_session *session, struct h2_stream *stream, const struct h2_priority *prio)
h2_session * h2_session_create(conn_rec *c, struct h2_ctx *ctx, struct h2_workers *workers)
Structure to store things which are per connection.
Definition: httpd.h:1110
int streams_reset
Definition: h2_session.h:110
server_rec * s
Definition: h2_session.h:82
Definition: h2_ctx.h:31
apr_int64_t apr_time_t
Definition: apr_time.h:45
Definition: h2.h:101
int initiated_on
Definition: h2_stream.h:46
apr_size_t frames_sent
Definition: h2_session.h:116
A structure to store information for each virtual server.
Definition: httpd.h:1302
unsigned int flush
Definition: h2_session.h:98
int h2_session_push_enabled(h2_session *session)
void h2_session_eoc_callback(h2_session *session)
int responses_submitted
Definition: h2_session.h:109
void h2_session_abort(h2_session *session, apr_status_t reason)
const struct h2_config * config
Definition: h2_session.h:83
struct h2_ihash_t h2_ihash_t
Definition: h2_util.h:41
unsigned int have_written
Definition: h2_session.h:100
apr_pool_t * pool
Definition: h2_session.h:84
Definition: h2_stream.h:44
struct apr_thread_cond_t * iowait
Definition: h2_session.h:125
apr_time_t idle_until
Definition: h2_session.h:121
struct h2_stream * h2_session_push(h2_session *session, struct h2_stream *is, struct h2_push *push)
int last_status_code
Definition: h2_session.h:128
conn_rec * c
Definition: h2_session.h:79
apr_status_t h2_session_stream_done(h2_session *session, struct h2_stream *stream)
h2_session * h2_session_rcreate(request_rec *r, struct h2_ctx *ctx, struct h2_workers *workers)
Definition: h2_push.h:40
Definition: h2_session.h:67
apr_status_t h2_session_pre_close(h2_session *session, int async)
struct h2_workers * workers
Definition: h2_session.h:86
int open_streams
Definition: h2_session.h:105
const char * last_status_msg
Definition: h2_session.h:129
Definition: h2_session.h:66
unsigned int have_read
Definition: h2_session.h:99
A structure that represents the current request.
Definition: httpd.h:805
struct h2_session h2_session
unsigned int eoc_written
Definition: h2_session.h:97
struct h2_stream * h2_session_open_stream(h2_session *session, int stream_id, int initiated_on, const h2_request *req)
Definition: h2_session.h:68
Definition: h2_session.h:72
Definition: h2_session.h:60
h2_conn_io io
Definition: h2_session.h:88
h2_session_state
Definition: h2.h:93
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
int unsent_promises
Definition: h2_session.h:107
h2_session_props local
Definition: h2_session.h:93
int apr_status_t
Definition: apr_errno.h:44
Definition: h2_session.h:69
request_rec * r
Definition: mod_dav.h:519
Definition: h2_session.h:70
Definition: apr_arch_thread_cond.h:34
apr_time_t keep_sync_until
Definition: h2_session.h:122
int pushes_promised
Definition: h2_session.h:111
h2_session_props remote
Definition: h2_session.h:94
Definition: h2_workers.h:33
void h2_session_close(h2_session *session)
struct h2_mplx * mplx
Definition: h2_session.h:85
Definition: h2_session.h:76
h2_session_event_t
Definition: h2_session.h:59
long id
Definition: h2_session.h:77
unsigned int reprioritize
Definition: h2_session.h:96
Definition: h2_filter.h:28