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 /* 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_conn_io.h"
21 
41 #include "h2.h"
42 
43 struct apr_thread_mutext_t;
44 struct apr_thread_cond_t;
45 struct h2_ctx;
46 struct h2_config;
47 struct h2_filter_cin;
48 struct h2_ihash_t;
49 struct h2_mplx;
50 struct h2_priority;
51 struct h2_push;
52 struct h2_push_diary;
53 struct h2_session;
54 struct h2_stream;
55 struct h2_stream_monitor;
56 struct h2_task;
57 struct h2_workers;
58 
59 struct nghttp2_session;
60 
61 typedef enum {
62  H2_SESSION_EV_INIT, /* session was initialized */
63  H2_SESSION_EV_LOCAL_GOAWAY, /* we send a GOAWAY */
64  H2_SESSION_EV_REMOTE_GOAWAY, /* remote send us a GOAWAY */
65  H2_SESSION_EV_CONN_ERROR, /* connection error */
66  H2_SESSION_EV_PROTO_ERROR, /* protocol error */
67  H2_SESSION_EV_CONN_TIMEOUT, /* connection timeout */
68  H2_SESSION_EV_NO_IO, /* nothing has been read or written */
69  H2_SESSION_EV_DATA_READ, /* connection data has been read */
70  H2_SESSION_EV_NGH2_DONE, /* nghttp2 wants neither read nor write anything */
71  H2_SESSION_EV_MPM_STOPPING, /* the process is stopping */
72  H2_SESSION_EV_PRE_CLOSE, /* connection will close after this */
74 
75 typedef struct h2_session {
76  long id; /* identifier of this session, unique
77  * inside a httpd process */
78  conn_rec *c; /* the connection this session serves */
79  request_rec *r; /* the request that started this in case
80  * of 'h2c', NULL otherwise */
81  server_rec *s; /* server/vhost we're starting on */
82  const struct h2_config *config; /* Relevant config for this session */
83  apr_pool_t *pool; /* pool to use in session */
84  struct h2_mplx *mplx; /* multiplexer for stream data */
85  struct h2_workers *workers; /* for executing stream tasks */
86  struct h2_filter_cin *cin; /* connection input filter context */
87  h2_conn_io io; /* io on httpd conn filters */
88  struct nghttp2_session *ngh2; /* the nghttp2 session (internal use) */
89 
90  h2_session_state state; /* state session is in */
91 
92  h2_session_props local; /* properties of local session */
93  h2_session_props remote; /* properites of remote session */
94 
95  unsigned int reprioritize : 1; /* scheduled streams priority changed */
96  unsigned int flush : 1; /* flushing output necessary */
97  unsigned int have_read : 1; /* session has read client data */
98  unsigned int have_written : 1; /* session did write data to client */
99  apr_interval_time_t wait_us; /* timeout during BUSY_WAIT state, micro secs */
100 
101  struct h2_push_diary *push_diary; /* remember pushes, avoid duplicates */
102 
103  struct h2_stream_monitor *monitor;/* monitor callbacks for streams */
104  int open_streams; /* number of client streams open */
105  int unsent_submits; /* number of submitted, but not yet written responses. */
106  int unsent_promises; /* number of submitted, but not yet written push promises */
107 
108  int responses_submitted; /* number of http/2 responses submitted */
109  int streams_reset; /* number of http/2 streams reset by client */
110  int pushes_promised; /* number of http/2 push promises submitted */
111  int pushes_submitted; /* number of http/2 pushed responses submitted */
112  int pushes_reset; /* number of http/2 pushed reset by client */
113 
114  apr_size_t frames_received; /* number of http/2 frames received */
115  apr_size_t frames_sent; /* number of http/2 frames sent */
116 
117  apr_size_t max_stream_count; /* max number of open streams */
118  apr_size_t max_stream_mem; /* max buffer memory for a single stream */
119 
120  apr_time_t idle_until; /* Time we shut down due to sheer boredom */
121  apr_time_t keep_sync_until; /* Time we sync wait until passing to async mpm */
122 
123  apr_bucket_brigade *bbtmp; /* brigade for keeping temporary data */
124  struct apr_thread_cond_t *iowait; /* our cond when trywaiting for data */
125 
126  char status[64]; /* status message for scoreboard */
127  int last_status_code; /* the one already reported */
128  const char *last_status_msg; /* the one already reported */
129 
130  struct h2_iqueue *in_pending; /* all streams with input pending */
131  struct h2_iqueue *in_process; /* all streams ready for processing on slave */
132 
133 } h2_session;
134 
135 const char *h2_session_state_str(h2_session_state state);
136 
147  conn_rec *c, struct h2_ctx *ctx,
148  struct h2_workers *workers);
149 
160  request_rec *r, struct h2_ctx *ctx,
161  struct h2_workers *workers);
162 
164  int err, const char *msg);
165 
172 apr_status_t h2_session_process(h2_session *session, int async);
173 
177 apr_status_t h2_session_pre_close(h2_session *session, int async);
178 
185 void h2_session_abort(h2_session *session, apr_status_t reason);
186 
190 void h2_session_close(h2_session *session);
191 
196 int h2_session_push_enabled(h2_session *session);
197 
208  struct h2_stream *is, struct h2_push *push);
209 
211  struct h2_stream *stream,
212  const struct h2_priority *prio);
213 
214 #define H2_SSSN_MSG(s, msg) \
215  "h2_session(%ld,%s,%d): "msg, s->id, h2_session_state_str(s->state), \
216  s->open_streams
217 
218 #define H2_SSSN_LOG(aplogno, s, msg) aplogno H2_SSSN_MSG(s, msg)
219 
220 #endif /* defined(__mod_h2__h2_session__) */
int unsent_submits
Definition: h2_session.h:105
int pushes_submitted
Definition: h2_session.h:111
size_t apr_size_t
Definition: apr.h:375
struct nghttp2_session * ngh2
Definition: h2_session.h:88
apr_size_t max_stream_mem
Definition: h2_session.h:118
Definition: h2_session.h:65
apr_size_t max_stream_count
Definition: h2_session.h:117
Definition: h2_task.h:53
char status[64]
Definition: h2_session.h:126
struct h2_session * session
Definition: h2_stream.h:69
Definition: h2_mplx.h:57
void h2_session_event(h2_session *session, h2_session_event_t ev, int err, const char *msg)
struct h2_filter_cin * cin
Definition: h2_session.h:86
request_rec * r
Definition: h2_session.h:79
Definition: h2_session.h:63
struct h2_iqueue * in_process
Definition: h2_session.h:131
int pushes_reset
Definition: h2_session.h:112
struct h2_stream_monitor * monitor
Definition: h2_session.h:103
Definition: h2_session.h:66
apr_size_t frames_received
Definition: h2_session.h:114
apr_interval_time_t wait_us
Definition: h2_session.h:99
Definition: h2.h:75
Definition: h2_session.h:67
struct h2_push_diary * push_diary
Definition: h2_session.h:101
Definition: h2_push.h:28
apr_status_t h2_session_process(h2_session *session, int async)
h2_session_state state
Definition: h2_session.h:90
apr_bucket_brigade * bbtmp
Definition: h2_session.h:123
Definition: h2_conn_io.h:29
Definition: h2_session.h:64
Definition: h2_session.h:72
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)
Structure to store things which are per connection.
Definition: httpd.h:1116
int streams_reset
Definition: h2_session.h:109
server_rec * s
Definition: h2_session.h:81
Definition: h2_ctx.h:32
apr_int64_t apr_time_t
Definition: apr_time.h:45
Definition: h2.h:96
apr_size_t frames_sent
Definition: h2_session.h:115
A structure to store information for each virtual server.
Definition: httpd.h:1310
unsigned int flush
Definition: h2_session.h:96
dav_error * err
Definition: mod_dav.h:203
int h2_session_push_enabled(h2_session *session)
int responses_submitted
Definition: h2_session.h:108
void h2_session_abort(h2_session *session, apr_status_t reason)
const struct h2_config * config
Definition: h2_session.h:82
struct h2_ihash_t h2_ihash_t
Definition: h2_util.h:42
unsigned int have_written
Definition: h2_session.h:98
apr_pool_t * pool
Definition: h2_session.h:83
Definition: h2_stream.h:65
struct apr_thread_cond_t * iowait
Definition: h2_session.h:124
apr_time_t idle_until
Definition: h2_session.h:120
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:127
conn_rec * c
Definition: h2_session.h:78
Definition: h2_push.h:42
const char * h2_session_state_str(h2_session_state state)
apr_status_t h2_session_pre_close(h2_session *session, int async)
struct h2_workers * workers
Definition: h2_session.h:85
int open_streams
Definition: h2_session.h:104
const char * last_status_msg
Definition: h2_session.h:128
Definition: h2_session.h:68
unsigned int have_read
Definition: h2_session.h:97
A structure that represents the current request.
Definition: httpd.h:806
struct h2_iqueue * in_pending
Definition: h2_session.h:130
struct h2_session h2_session
Definition: h2_stream.h:54
Definition: h2_session.h:69
Definition: h2_session.h:62
h2_conn_io io
Definition: h2_session.h:87
h2_session_state
Definition: h2.h:87
Definition: h2_util.h:76
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
int unsent_promises
Definition: h2_session.h:106
h2_session_props local
Definition: h2_session.h:92
int apr_status_t
Definition: apr_errno.h:44
Definition: h2_session.h:70
request_rec * r
Definition: mod_dav.h:515
Definition: h2_session.h:71
Definition: apr_arch_thread_cond.h:34
apr_time_t keep_sync_until
Definition: h2_session.h:121
int pushes_promised
Definition: h2_session.h:110
h2_session_props remote
Definition: h2_session.h:93
Definition: h2_workers.h:36
apr_status_t h2_session_create(h2_session **psession, conn_rec *c, struct h2_ctx *ctx, struct h2_workers *workers)
void h2_session_close(h2_session *session)
struct h2_mplx * mplx
Definition: h2_session.h:84
Definition: h2_session.h:75
h2_session_event_t
Definition: h2_session.h:61
long id
Definition: h2_session.h:76
unsigned int reprioritize
Definition: h2_session.h:95
apr_status_t h2_session_rcreate(h2_session **psession, request_rec *r, struct h2_ctx *ctx, struct h2_workers *workers)
Definition: h2_filter.h:25