Apache2
h2_proxy_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 h2_proxy_session_h
18 #define h2_proxy_session_h
19 
20 #define H2_ALEN(a) (sizeof(a)/sizeof((a)[0]))
21 
22 #include <nghttp2/nghttp2.h>
23 
24 struct h2_proxy_iqueue;
25 struct h2_proxy_ihash_t;
26 
27 typedef enum {
36 
37 typedef enum {
38  H2_PROXYS_ST_INIT, /* send initial SETTINGS, etc. */
39  H2_PROXYS_ST_DONE, /* finished, connection close */
40  H2_PROXYS_ST_IDLE, /* no streams to process */
41  H2_PROXYS_ST_BUSY, /* read/write without stop */
42  H2_PROXYS_ST_WAIT, /* waiting for tasks reporting back */
43  H2_PROXYS_ST_LOCAL_SHUTDOWN, /* we announced GOAWAY */
44  H2_PROXYS_ST_REMOTE_SHUTDOWN, /* client announced GOAWAY */
46 
47 typedef enum {
48  H2_PROXYS_EV_INIT, /* session was initialized */
49  H2_PROXYS_EV_LOCAL_GOAWAY, /* we send a GOAWAY */
50  H2_PROXYS_EV_REMOTE_GOAWAY, /* remote send us a GOAWAY */
51  H2_PROXYS_EV_CONN_ERROR, /* connection error */
52  H2_PROXYS_EV_PROTO_ERROR, /* protocol error */
53  H2_PROXYS_EV_CONN_TIMEOUT, /* connection timeout */
54  H2_PROXYS_EV_NO_IO, /* nothing has been read or written */
55  H2_PROXYS_EV_STREAM_SUBMITTED, /* stream has been submitted */
56  H2_PROXYS_EV_STREAM_DONE, /* stream has been finished */
57  H2_PROXYS_EV_STREAM_RESUMED, /* stream signalled availability of headers/data */
58  H2_PROXYS_EV_DATA_READ, /* connection data has been read */
59  H2_PROXYS_EV_NGH2_DONE, /* nghttp2 wants neither read nor write anything */
60  H2_PROXYS_EV_PRE_CLOSE, /* connection will close after this */
62 
63 typedef enum {
64  H2_PING_ST_NONE, /* normal connection mode, ProxyTimeout rules */
65  H2_PING_ST_AWAIT_ANY, /* waiting for any frame from backend */
66  H2_PING_ST_AWAIT_PING, /* waiting for PING frame from backend */
68 
69 typedef struct h2_proxy_session h2_proxy_session;
71  apr_status_t status, int touched,
72  int error_code);
73 
75  const char *id;
80  nghttp2_session *ngh2; /* the nghttp2 session itself */
81 
82  unsigned int aborted : 1;
83  unsigned int h2_front : 1; /* if front-end connection is HTTP/2 */
84 
86  void *user_data;
87 
88  unsigned char window_bits_stream;
89  unsigned char window_bits_connection;
90 
93 
97  int last_stream_id; /* last stream id processed by backend, or 0 */
99 
102 
106 };
107 
110  int h2_front,
111  unsigned char window_bits_connection,
112  unsigned char window_bits_stream,
113  h2_proxy_request_done *done);
114 
116  request_rec *r, int standalone);
117 
127 
129 
131 
132 #define H2_PROXY_REQ_URL_NOTE "h2-proxy-req-url"
133 
135 
136 #endif /* h2_proxy_session_h */
request_rec * r
Definition: mod_dav.h:518
int status
Definition: mod_dav.h:141
const char * s
Definition: mod_dav.h:1327
proxy_worker proxy_server_conf * conf
Definition: mod_proxy.h:657
proxy_worker proxy_server_conf char * url
Definition: mod_proxy.h:657
int apr_status_t
Definition: apr_errno.h:44
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
void h2_proxy_session_cleanup(h2_proxy_session *s, h2_proxy_request_done *done)
h2_ping_state_t
Definition: h2_proxy_session.h:63
@ H2_PING_ST_AWAIT_ANY
Definition: h2_proxy_session.h:65
@ H2_PING_ST_AWAIT_PING
Definition: h2_proxy_session.h:66
@ H2_PING_ST_NONE
Definition: h2_proxy_session.h:64
h2_proxy_stream_state_t
Definition: h2_proxy_session.h:27
@ H2_STREAM_ST_IDLE
Definition: h2_proxy_session.h:28
@ H2_STREAM_ST_CLOSED_OUTPUT
Definition: h2_proxy_session.h:33
@ H2_STREAM_ST_RESV_LOCAL
Definition: h2_proxy_session.h:30
@ H2_STREAM_ST_CLOSED_INPUT
Definition: h2_proxy_session.h:32
@ H2_STREAM_ST_RESV_REMOTE
Definition: h2_proxy_session.h:31
@ H2_STREAM_ST_OPEN
Definition: h2_proxy_session.h:29
@ H2_STREAM_ST_CLOSED
Definition: h2_proxy_session.h:34
h2_proxy_session * h2_proxy_session_setup(const char *id, proxy_conn_rec *p_conn, proxy_server_conf *conf, int h2_front, unsigned char window_bits_connection, unsigned char window_bits_stream, h2_proxy_request_done *done)
h2_proxys_state
Definition: h2_proxy_session.h:37
@ H2_PROXYS_ST_LOCAL_SHUTDOWN
Definition: h2_proxy_session.h:43
@ H2_PROXYS_ST_DONE
Definition: h2_proxy_session.h:39
@ H2_PROXYS_ST_BUSY
Definition: h2_proxy_session.h:41
@ H2_PROXYS_ST_WAIT
Definition: h2_proxy_session.h:42
@ H2_PROXYS_ST_IDLE
Definition: h2_proxy_session.h:40
@ H2_PROXYS_ST_REMOTE_SHUTDOWN
Definition: h2_proxy_session.h:44
@ H2_PROXYS_ST_INIT
Definition: h2_proxy_session.h:38
void h2_proxy_request_done(h2_proxy_session *s, request_rec *r, apr_status_t status, int touched, int error_code)
Definition: h2_proxy_session.h:70
h2_proxys_event_t
Definition: h2_proxy_session.h:47
@ H2_PROXYS_EV_CONN_TIMEOUT
Definition: h2_proxy_session.h:53
@ H2_PROXYS_EV_STREAM_RESUMED
Definition: h2_proxy_session.h:57
@ H2_PROXYS_EV_NO_IO
Definition: h2_proxy_session.h:54
@ H2_PROXYS_EV_STREAM_DONE
Definition: h2_proxy_session.h:56
@ H2_PROXYS_EV_PRE_CLOSE
Definition: h2_proxy_session.h:60
@ H2_PROXYS_EV_PROTO_ERROR
Definition: h2_proxy_session.h:52
@ H2_PROXYS_EV_DATA_READ
Definition: h2_proxy_session.h:58
@ H2_PROXYS_EV_NGH2_DONE
Definition: h2_proxy_session.h:59
@ H2_PROXYS_EV_CONN_ERROR
Definition: h2_proxy_session.h:51
@ H2_PROXYS_EV_REMOTE_GOAWAY
Definition: h2_proxy_session.h:50
@ H2_PROXYS_EV_INIT
Definition: h2_proxy_session.h:48
@ H2_PROXYS_EV_LOCAL_GOAWAY
Definition: h2_proxy_session.h:49
@ H2_PROXYS_EV_STREAM_SUBMITTED
Definition: h2_proxy_session.h:55
apr_status_t h2_proxy_session_process(h2_proxy_session *s)
int h2_proxy_session_is_reusable(h2_proxy_session *s)
apr_status_t h2_proxy_session_submit(h2_proxy_session *s, const char *url, request_rec *r, int standalone)
void h2_proxy_session_cancel_all(h2_proxy_session *s)
struct h2_proxy_ihash_t h2_proxy_ihash_t
Definition: h2_proxy_util.h:31
Definition: apr_buckets.h:263
Structure to store things which are per connection.
Definition: httpd.h:1193
Definition: h2_proxy_util.h:66
Definition: h2_proxy_session.h:74
unsigned int h2_front
Definition: h2_proxy_session.h:83
apr_time_t ping_timeout
Definition: h2_proxy_session.h:104
h2_proxy_request_done * done
Definition: h2_proxy_session.h:85
proxy_conn_rec * p_conn
Definition: h2_proxy_session.h:77
apr_interval_time_t wait_timeout
Definition: h2_proxy_session.h:92
apr_bucket_brigade * output
Definition: h2_proxy_session.h:101
void * user_data
Definition: h2_proxy_session.h:86
apr_bucket_brigade * input
Definition: h2_proxy_session.h:100
unsigned char window_bits_stream
Definition: h2_proxy_session.h:88
apr_time_t save_timeout
Definition: h2_proxy_session.h:105
h2_ping_state_t ping_state
Definition: h2_proxy_session.h:103
apr_time_t last_frame_received
Definition: h2_proxy_session.h:98
apr_size_t remote_max_concurrent
Definition: h2_proxy_session.h:96
struct h2_proxy_ihash_t * streams
Definition: h2_proxy_session.h:94
proxy_server_conf * conf
Definition: h2_proxy_session.h:78
conn_rec * c
Definition: h2_proxy_session.h:76
unsigned char window_bits_connection
Definition: h2_proxy_session.h:89
nghttp2_session * ngh2
Definition: h2_proxy_session.h:80
const char * id
Definition: h2_proxy_session.h:75
int last_stream_id
Definition: h2_proxy_session.h:97
h2_proxys_state state
Definition: h2_proxy_session.h:91
struct h2_proxy_iqueue * suspended
Definition: h2_proxy_session.h:95
unsigned int aborted
Definition: h2_proxy_session.h:82
apr_pool_t * pool
Definition: h2_proxy_session.h:79
Definition: mod_proxy.h:274
Definition: mod_proxy.h:154
A structure that represents the current request.
Definition: httpd.h:856