Craig Tiller | 640d3bd | 2015-06-12 07:51:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright 2015, Google Inc. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are |
| 8 | * met: |
| 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * * Redistributions in binary form must reproduce the above |
| 13 | * copyright notice, this list of conditions and the following disclaimer |
| 14 | * in the documentation and/or other materials provided with the |
| 15 | * distribution. |
| 16 | * * Neither the name of Google Inc. nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | * |
| 32 | */ |
| 33 | |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 34 | #ifndef GRPC_INTERNAL_CORE_CHTTP2_INTERNAL_H |
| 35 | #define GRPC_INTERNAL_CORE_CHTTP2_INTERNAL_H |
| 36 | |
| 37 | #include "src/core/transport/transport_impl.h" |
Craig Tiller | 3208e39 | 2015-06-12 08:17:02 -0700 | [diff] [blame] | 38 | #include "src/core/iomgr/endpoint.h" |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 39 | #include "src/core/transport/chttp2/frame.h" |
Craig Tiller | 3208e39 | 2015-06-12 08:17:02 -0700 | [diff] [blame] | 40 | #include "src/core/transport/chttp2/frame_data.h" |
| 41 | #include "src/core/transport/chttp2/frame_goaway.h" |
| 42 | #include "src/core/transport/chttp2/frame_ping.h" |
| 43 | #include "src/core/transport/chttp2/frame_rst_stream.h" |
| 44 | #include "src/core/transport/chttp2/frame_settings.h" |
| 45 | #include "src/core/transport/chttp2/frame_window_update.h" |
Craig Tiller | 3208e39 | 2015-06-12 08:17:02 -0700 | [diff] [blame] | 46 | #include "src/core/transport/chttp2/hpack_parser.h" |
Craig Tiller | 5dc3b30 | 2015-06-15 16:06:50 -0700 | [diff] [blame] | 47 | #include "src/core/transport/chttp2/incoming_metadata.h" |
Craig Tiller | 3208e39 | 2015-06-12 08:17:02 -0700 | [diff] [blame] | 48 | #include "src/core/transport/chttp2/stream_encoder.h" |
Craig Tiller | 5dc3b30 | 2015-06-15 16:06:50 -0700 | [diff] [blame] | 49 | #include "src/core/transport/chttp2/stream_map.h" |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 50 | |
Craig Tiller | b084d90 | 2015-06-12 07:50:02 -0700 | [diff] [blame] | 51 | typedef struct grpc_chttp2_transport grpc_chttp2_transport; |
| 52 | typedef struct grpc_chttp2_stream grpc_chttp2_stream; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 53 | |
| 54 | /* streams are kept in various linked lists depending on what things need to |
| 55 | happen to them... this enum labels each list */ |
| 56 | typedef enum { |
Craig Tiller | 5dc3b30 | 2015-06-15 16:06:50 -0700 | [diff] [blame] | 57 | GRPC_CHTTP2_LIST_ALL_STREAMS, |
Craig Tiller | 6459db4 | 2015-06-15 17:11:45 -0700 | [diff] [blame] | 58 | GRPC_CHTTP2_LIST_READ_WRITE_STATE_CHANGED, |
| 59 | GRPC_CHTTP2_LIST_INCOMING_WINDOW_STATE_CHANGED, |
Craig Tiller | 5dc3b30 | 2015-06-15 16:06:50 -0700 | [diff] [blame] | 60 | GRPC_CHTTP2_LIST_WRITABLE, |
Craig Tiller | 6459db4 | 2015-06-15 17:11:45 -0700 | [diff] [blame] | 61 | GRPC_CHTTP2_LIST_WRITING, |
| 62 | GRPC_CHTTP2_LIST_WRITTEN, |
| 63 | GRPC_CHTTP2_LIST_WRITABLE_WINDOW_UPDATE, |
| 64 | GRPC_CHTTP2_LIST_PARSING_SEEN, |
Craig Tiller | 83fb070 | 2015-06-16 21:13:07 -0700 | [diff] [blame^] | 65 | GRPC_CHTTP2_LIST_CLOSED_WAITING_FOR_PARSING, |
Craig Tiller | cf1e319 | 2015-06-16 14:28:22 -0700 | [diff] [blame] | 66 | GRPC_CHTTP2_LIST_INCOMING_WINDOW_UPDATED, |
Craig Tiller | 5dc3b30 | 2015-06-15 16:06:50 -0700 | [diff] [blame] | 67 | /** streams that are waiting to start because there are too many concurrent |
| 68 | streams on the connection */ |
| 69 | GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY, |
| 70 | #if 0 |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 71 | /* streams that have pending writes */ |
| 72 | WRITABLE = 0, |
| 73 | /* streams that have been selected to be written */ |
| 74 | WRITING, |
| 75 | /* streams that have just been written, and included a close */ |
| 76 | WRITTEN_CLOSED, |
| 77 | /* streams that have been cancelled and have some pending state updates |
| 78 | to perform */ |
| 79 | CANCELLED, |
| 80 | /* streams that want to send window updates */ |
| 81 | WINDOW_UPDATE, |
| 82 | /* streams that are waiting to start because there are too many concurrent |
| 83 | streams on the connection */ |
| 84 | WAITING_FOR_CONCURRENCY, |
| 85 | /* streams that have finished reading: we wait until unlock to coalesce |
| 86 | all changes into one callback */ |
| 87 | FINISHED_READ_OP, |
| 88 | MAYBE_FINISH_READ_AFTER_PARSE, |
| 89 | PARSER_CHECK_WINDOW_UPDATES_AFTER_PARSE, |
| 90 | OTHER_CHECK_WINDOW_UPDATES_AFTER_PARSE, |
| 91 | NEW_OUTGOING_WINDOW, |
Craig Tiller | 9850510 | 2015-06-16 11:33:15 -0700 | [diff] [blame] | 92 | #endif |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 93 | STREAM_LIST_COUNT /* must be last */ |
Craig Tiller | b084d90 | 2015-06-12 07:50:02 -0700 | [diff] [blame] | 94 | } grpc_chttp2_stream_list_id; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 95 | |
| 96 | /* deframer state for the overall http2 stream of bytes */ |
| 97 | typedef enum { |
| 98 | /* prefix: one entry per http2 connection prefix byte */ |
| 99 | DTS_CLIENT_PREFIX_0 = 0, |
| 100 | DTS_CLIENT_PREFIX_1, |
| 101 | DTS_CLIENT_PREFIX_2, |
| 102 | DTS_CLIENT_PREFIX_3, |
| 103 | DTS_CLIENT_PREFIX_4, |
| 104 | DTS_CLIENT_PREFIX_5, |
| 105 | DTS_CLIENT_PREFIX_6, |
| 106 | DTS_CLIENT_PREFIX_7, |
| 107 | DTS_CLIENT_PREFIX_8, |
| 108 | DTS_CLIENT_PREFIX_9, |
| 109 | DTS_CLIENT_PREFIX_10, |
| 110 | DTS_CLIENT_PREFIX_11, |
| 111 | DTS_CLIENT_PREFIX_12, |
| 112 | DTS_CLIENT_PREFIX_13, |
| 113 | DTS_CLIENT_PREFIX_14, |
| 114 | DTS_CLIENT_PREFIX_15, |
| 115 | DTS_CLIENT_PREFIX_16, |
| 116 | DTS_CLIENT_PREFIX_17, |
| 117 | DTS_CLIENT_PREFIX_18, |
| 118 | DTS_CLIENT_PREFIX_19, |
| 119 | DTS_CLIENT_PREFIX_20, |
| 120 | DTS_CLIENT_PREFIX_21, |
| 121 | DTS_CLIENT_PREFIX_22, |
| 122 | DTS_CLIENT_PREFIX_23, |
| 123 | /* frame header byte 0... */ |
| 124 | /* must follow from the prefix states */ |
| 125 | DTS_FH_0, |
| 126 | DTS_FH_1, |
| 127 | DTS_FH_2, |
| 128 | DTS_FH_3, |
| 129 | DTS_FH_4, |
| 130 | DTS_FH_5, |
| 131 | DTS_FH_6, |
| 132 | DTS_FH_7, |
| 133 | /* ... frame header byte 8 */ |
| 134 | DTS_FH_8, |
| 135 | /* inside a http2 frame */ |
| 136 | DTS_FRAME |
Craig Tiller | b084d90 | 2015-06-12 07:50:02 -0700 | [diff] [blame] | 137 | } grpc_chttp2_deframe_transport_state; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 138 | |
| 139 | typedef enum { |
| 140 | WRITE_STATE_OPEN, |
| 141 | WRITE_STATE_QUEUED_CLOSE, |
| 142 | WRITE_STATE_SENT_CLOSE |
Craig Tiller | b084d90 | 2015-06-12 07:50:02 -0700 | [diff] [blame] | 143 | } grpc_chttp2_write_state; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 144 | |
| 145 | typedef enum { |
| 146 | DONT_SEND_CLOSED = 0, |
| 147 | SEND_CLOSED, |
| 148 | SEND_CLOSED_WITH_RST_STREAM |
Craig Tiller | b084d90 | 2015-06-12 07:50:02 -0700 | [diff] [blame] | 149 | } grpc_chttp2_send_closed; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 150 | |
| 151 | typedef struct { |
Craig Tiller | b084d90 | 2015-06-12 07:50:02 -0700 | [diff] [blame] | 152 | grpc_chttp2_stream *head; |
| 153 | grpc_chttp2_stream *tail; |
| 154 | } grpc_chttp2_stream_list; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 155 | |
| 156 | typedef struct { |
Craig Tiller | b084d90 | 2015-06-12 07:50:02 -0700 | [diff] [blame] | 157 | grpc_chttp2_stream *next; |
| 158 | grpc_chttp2_stream *prev; |
| 159 | } grpc_chttp2_stream_link; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 160 | |
| 161 | typedef enum { |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 162 | GRPC_CHTTP2_ERROR_STATE_NONE, |
| 163 | GRPC_CHTTP2_ERROR_STATE_SEEN, |
| 164 | GRPC_CHTTP2_ERROR_STATE_NOTIFIED |
Craig Tiller | b084d90 | 2015-06-12 07:50:02 -0700 | [diff] [blame] | 165 | } grpc_chttp2_error_state; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 166 | |
| 167 | /* We keep several sets of connection wide parameters */ |
| 168 | typedef enum { |
| 169 | /* The settings our peer has asked for (and we have acked) */ |
| 170 | PEER_SETTINGS = 0, |
| 171 | /* The settings we'd like to have */ |
| 172 | LOCAL_SETTINGS, |
| 173 | /* The settings we've published to our peer */ |
| 174 | SENT_SETTINGS, |
| 175 | /* The settings the peer has acked */ |
| 176 | ACKED_SETTINGS, |
| 177 | NUM_SETTING_SETS |
Craig Tiller | b084d90 | 2015-06-12 07:50:02 -0700 | [diff] [blame] | 178 | } grpc_chttp2_setting_set; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 179 | |
| 180 | /* Outstanding ping request data */ |
Craig Tiller | 3719f07 | 2015-06-12 17:19:51 -0700 | [diff] [blame] | 181 | typedef struct grpc_chttp2_outstanding_ping { |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 182 | gpr_uint8 id[8]; |
Craig Tiller | 3719f07 | 2015-06-12 17:19:51 -0700 | [diff] [blame] | 183 | grpc_iomgr_closure *on_recv; |
| 184 | struct grpc_chttp2_outstanding_ping *next; |
| 185 | struct grpc_chttp2_outstanding_ping *prev; |
Craig Tiller | b084d90 | 2015-06-12 07:50:02 -0700 | [diff] [blame] | 186 | } grpc_chttp2_outstanding_ping; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 187 | |
| 188 | typedef struct { |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 189 | /** data to write next write */ |
| 190 | gpr_slice_buffer qbuf; |
| 191 | /** queued callbacks */ |
| 192 | grpc_iomgr_closure *pending_closures; |
| 193 | |
| 194 | /** window available for us to send to peer */ |
| 195 | gpr_uint32 outgoing_window; |
Craig Tiller | 3719f07 | 2015-06-12 17:19:51 -0700 | [diff] [blame] | 196 | /** window available for peer to send to us - updated after parse */ |
| 197 | gpr_uint32 incoming_window; |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 198 | /** how much window would we like to have for incoming_window */ |
| 199 | gpr_uint32 connection_window_target; |
| 200 | |
Craig Tiller | 3719f07 | 2015-06-12 17:19:51 -0700 | [diff] [blame] | 201 | /** is this transport a client? */ |
| 202 | gpr_uint8 is_client; |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 203 | /** are the local settings dirty and need to be sent? */ |
| 204 | gpr_uint8 dirtied_local_settings; |
| 205 | /** have local settings been sent? */ |
| 206 | gpr_uint8 sent_local_settings; |
| 207 | /** bitmask of setting indexes to send out */ |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 208 | gpr_uint32 force_send_settings; |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 209 | /** settings values */ |
| 210 | gpr_uint32 settings[NUM_SETTING_SETS][GRPC_CHTTP2_NUM_SETTINGS]; |
| 211 | |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 212 | /** has there been a connection level error, and have we notified |
| 213 | anyone about it? */ |
| 214 | grpc_chttp2_error_state error_state; |
| 215 | |
| 216 | /** what is the next stream id to be allocated by this peer? |
| 217 | copied to next_stream_id in parsing when parsing commences */ |
| 218 | gpr_uint32 next_stream_id; |
| 219 | |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 220 | /** last received stream id */ |
| 221 | gpr_uint32 last_incoming_stream_id; |
Craig Tiller | 3719f07 | 2015-06-12 17:19:51 -0700 | [diff] [blame] | 222 | |
| 223 | /** pings awaiting responses */ |
| 224 | grpc_chttp2_outstanding_ping pings; |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 225 | /** next payload for an outgoing ping */ |
| 226 | gpr_uint64 ping_counter; |
| 227 | |
| 228 | /** concurrent stream count: updated when not parsing, |
| 229 | so this is a strict over-estimation on the client */ |
| 230 | gpr_uint32 concurrent_stream_count; |
| 231 | |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 232 | /** is there a goaway available? (boolean) */ |
| 233 | grpc_chttp2_error_state goaway_state; |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 234 | /** what is the debug text of the goaway? */ |
| 235 | gpr_slice goaway_text; |
| 236 | /** what is the status code of the goaway? */ |
| 237 | grpc_status_code goaway_error; |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 238 | } grpc_chttp2_transport_global; |
| 239 | |
| 240 | typedef struct { |
| 241 | /** data to write now */ |
| 242 | gpr_slice_buffer outbuf; |
| 243 | /** hpack encoding */ |
| 244 | grpc_chttp2_hpack_compressor hpack_compressor; |
| 245 | } grpc_chttp2_transport_writing; |
| 246 | |
| 247 | struct grpc_chttp2_transport_parsing { |
| 248 | /** is this transport a client? (boolean) */ |
| 249 | gpr_uint8 is_client; |
| 250 | |
| 251 | /** were settings updated? */ |
| 252 | gpr_uint8 settings_updated; |
| 253 | /** was a settings ack received? */ |
| 254 | gpr_uint8 settings_ack_received; |
| 255 | /** was a goaway frame received? */ |
| 256 | gpr_uint8 goaway_received; |
| 257 | |
Craig Tiller | 3719f07 | 2015-06-12 17:19:51 -0700 | [diff] [blame] | 258 | /** initial window change */ |
| 259 | gpr_int64 initial_window_update; |
| 260 | |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 261 | /** data to write later - after parsing */ |
| 262 | gpr_slice_buffer qbuf; |
| 263 | /* metadata object cache */ |
| 264 | grpc_mdstr *str_grpc_timeout; |
| 265 | /** parser for headers */ |
| 266 | grpc_chttp2_hpack_parser hpack_parser; |
| 267 | /** simple one shot parsers */ |
| 268 | union { |
| 269 | grpc_chttp2_window_update_parser window_update; |
| 270 | grpc_chttp2_settings_parser settings; |
| 271 | grpc_chttp2_ping_parser ping; |
| 272 | grpc_chttp2_rst_stream_parser rst_stream; |
| 273 | } simple; |
| 274 | /** parser for goaway frames */ |
| 275 | grpc_chttp2_goaway_parser goaway_parser; |
| 276 | |
| 277 | /** window available for peer to send to us */ |
| 278 | gpr_uint32 incoming_window; |
| 279 | |
| 280 | /** next stream id available at the time of beginning parsing */ |
| 281 | gpr_uint32 next_stream_id; |
| 282 | gpr_uint32 last_incoming_stream_id; |
| 283 | |
| 284 | /* deframing */ |
| 285 | grpc_chttp2_deframe_transport_state deframe_state; |
| 286 | gpr_uint8 incoming_frame_type; |
| 287 | gpr_uint8 incoming_frame_flags; |
| 288 | gpr_uint8 header_eof; |
| 289 | gpr_uint32 expect_continuation_stream_id; |
| 290 | gpr_uint32 incoming_frame_size; |
| 291 | gpr_uint32 incoming_stream_id; |
| 292 | |
| 293 | /* active parser */ |
| 294 | void *parser_data; |
| 295 | grpc_chttp2_stream_parsing *incoming_stream; |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 296 | grpc_chttp2_parse_error (*parser)( |
| 297 | void *parser_user_data, grpc_chttp2_transport_parsing *transport_parsing, |
| 298 | grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last); |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 299 | |
| 300 | /* received settings */ |
| 301 | gpr_uint32 settings[GRPC_CHTTP2_NUM_SETTINGS]; |
| 302 | |
| 303 | /* goaway data */ |
| 304 | grpc_status_code goaway_error; |
| 305 | gpr_uint32 goaway_last_stream_index; |
| 306 | gpr_slice goaway_text; |
Craig Tiller | 3719f07 | 2015-06-12 17:19:51 -0700 | [diff] [blame] | 307 | |
| 308 | gpr_uint64 outgoing_window_update; |
| 309 | |
| 310 | /** pings awaiting responses */ |
| 311 | grpc_chttp2_outstanding_ping pings; |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 312 | }; |
| 313 | |
Craig Tiller | b084d90 | 2015-06-12 07:50:02 -0700 | [diff] [blame] | 314 | struct grpc_chttp2_transport { |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 315 | grpc_transport base; /* must be first */ |
| 316 | grpc_endpoint *ep; |
| 317 | grpc_mdctx *metadata_context; |
| 318 | gpr_refcount refs; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 319 | |
| 320 | gpr_mu mu; |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 321 | |
| 322 | /** is the transport destroying itself? */ |
| 323 | gpr_uint8 destroying; |
| 324 | /** has the upper layer closed the transport? */ |
| 325 | gpr_uint8 closed; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 326 | |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 327 | /** is a thread currently writing */ |
| 328 | gpr_uint8 writing_active; |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 329 | /** is a thread currently parsing */ |
| 330 | gpr_uint8 parsing_active; |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 331 | |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 332 | /** is there a read request to the endpoint outstanding? */ |
| 333 | gpr_uint8 endpoint_reading; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 334 | |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 335 | /** various lists of streams */ |
Craig Tiller | b084d90 | 2015-06-12 07:50:02 -0700 | [diff] [blame] | 336 | grpc_chttp2_stream_list lists[STREAM_LIST_COUNT]; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 337 | |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 338 | /** global state for reading/writing */ |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 339 | grpc_chttp2_transport_global global; |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 340 | /** state only accessible by the chain of execution that |
| 341 | set writing_active=1 */ |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 342 | grpc_chttp2_transport_writing writing; |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 343 | /** state only accessible by the chain of execution that |
| 344 | set parsing_active=1 */ |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 345 | grpc_chttp2_transport_parsing parsing; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 346 | |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 347 | /** maps stream id to grpc_chttp2_stream objects; |
| 348 | owned by the parsing thread when parsing */ |
| 349 | grpc_chttp2_stream_map parsing_stream_map; |
| 350 | |
| 351 | /** streams created by the client (possibly during parsing); |
| 352 | merged with parsing_stream_map during unlock when no |
| 353 | parsing is occurring */ |
| 354 | grpc_chttp2_stream_map new_stream_map; |
| 355 | |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 356 | /** closure to execute writing */ |
| 357 | grpc_iomgr_closure writing_action; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 358 | |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 359 | /** address to place a newly accepted stream - set and unset by |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 360 | grpc_chttp2_parsing_accept_stream; used by init_stream to |
| 361 | publish the accepted server stream */ |
| 362 | grpc_chttp2_stream **accepting_stream; |
| 363 | |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 364 | struct { |
| 365 | /** is a thread currently performing channel callbacks */ |
| 366 | gpr_uint8 executing; |
| 367 | /** transport channel-level callback */ |
| 368 | const grpc_transport_callbacks *cb; |
| 369 | /** user data for cb calls */ |
| 370 | void *cb_user_data; |
| 371 | /** closure for notifying transport closure */ |
| 372 | grpc_iomgr_closure notify_closed; |
| 373 | } channel_callback; |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 374 | |
| 375 | #if 0 |
| 376 | /* basic state management - what are we doing at the moment? */ |
| 377 | gpr_uint8 reading; |
| 378 | /** are we calling back any grpc_transport_op completion events */ |
| 379 | gpr_uint8 calling_back_ops; |
| 380 | gpr_uint8 destroying; |
| 381 | gpr_uint8 closed; |
| 382 | |
| 383 | /* stream indexing */ |
| 384 | gpr_uint32 next_stream_id; |
| 385 | |
| 386 | /* window management */ |
| 387 | gpr_uint32 outgoing_window_update; |
| 388 | |
| 389 | /* state for a stream that's not yet been created */ |
| 390 | grpc_stream_op_buffer new_stream_sopb; |
| 391 | |
| 392 | /* stream ops that need to be destroyed, but outside of the lock */ |
| 393 | grpc_stream_op_buffer nuke_later_sopb; |
| 394 | |
| 395 | /* pings */ |
| 396 | gpr_int64 ping_counter; |
| 397 | |
| 398 | |
| 399 | grpc_chttp2_stream **accepting_stream; |
| 400 | |
| 401 | #endif |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 402 | }; |
| 403 | |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 404 | typedef struct { |
| 405 | /** HTTP2 stream id for this stream, or zero if one has not been assigned */ |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 406 | gpr_uint32 id; |
| 407 | |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 408 | grpc_iomgr_closure *send_done_closure; |
| 409 | grpc_iomgr_closure *recv_done_closure; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 410 | |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 411 | /** window available for us to send to peer */ |
| 412 | gpr_int64 outgoing_window; |
Craig Tiller | 3719f07 | 2015-06-12 17:19:51 -0700 | [diff] [blame] | 413 | /** window available for peer to send to us - updated after parse */ |
| 414 | gpr_uint32 incoming_window; |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 415 | /** stream ops the transport user would like to send */ |
| 416 | grpc_stream_op_buffer *outgoing_sopb; |
| 417 | /** when the application requests writes be closed, the write_closed is |
| 418 | 'queued'; when the close is flow controlled into the send path, we are |
| 419 | 'sending' it; when the write has been performed it is 'sent' */ |
| 420 | grpc_chttp2_write_state write_state; |
| 421 | /** is this stream closed (boolean) */ |
| 422 | gpr_uint8 read_closed; |
Craig Tiller | 5dc3b30 | 2015-06-15 16:06:50 -0700 | [diff] [blame] | 423 | /** has this stream been cancelled? (boolean) */ |
| 424 | gpr_uint8 cancelled; |
| 425 | /** is this stream in the stream map? (boolean) */ |
| 426 | gpr_uint8 in_stream_map; |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 427 | |
| 428 | /** stream state already published to the upper layer */ |
| 429 | grpc_stream_state published_state; |
| 430 | /** address to publish next stream state to */ |
| 431 | grpc_stream_state *publish_state; |
| 432 | /** pointer to sop buffer to fill in with new stream ops */ |
Craig Tiller | 6905b7c | 2015-06-16 15:33:33 -0700 | [diff] [blame] | 433 | grpc_stream_op_buffer *publish_sopb; |
| 434 | grpc_stream_op_buffer incoming_sopb; |
Craig Tiller | 5dc3b30 | 2015-06-15 16:06:50 -0700 | [diff] [blame] | 435 | |
| 436 | /** incoming metadata */ |
| 437 | grpc_chttp2_incoming_metadata_buffer incoming_metadata; |
Craig Tiller | b787c50 | 2015-06-15 16:14:52 -0700 | [diff] [blame] | 438 | grpc_chttp2_incoming_metadata_live_op_buffer outstanding_metadata; |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 439 | } grpc_chttp2_stream_global; |
| 440 | |
| 441 | typedef struct { |
| 442 | /** HTTP2 stream id for this stream, or zero if one has not been assigned */ |
| 443 | gpr_uint32 id; |
| 444 | /** sops that have passed flow control to be written */ |
| 445 | grpc_stream_op_buffer sopb; |
| 446 | /** how strongly should we indicate closure with the next write */ |
| 447 | grpc_chttp2_send_closed send_closed; |
| 448 | } grpc_chttp2_stream_writing; |
| 449 | |
| 450 | struct grpc_chttp2_stream_parsing { |
| 451 | /** HTTP2 stream id for this stream, or zero if one has not been assigned */ |
| 452 | gpr_uint32 id; |
| 453 | /** has this stream received a close */ |
| 454 | gpr_uint8 received_close; |
Craig Tiller | 3719f07 | 2015-06-12 17:19:51 -0700 | [diff] [blame] | 455 | /** saw a rst_stream */ |
| 456 | gpr_uint8 saw_rst_stream; |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 457 | /** incoming_window has been reduced by this much during parsing */ |
| 458 | gpr_uint32 incoming_window_delta; |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 459 | /** window available for peer to send to us */ |
| 460 | gpr_uint32 incoming_window; |
| 461 | /** parsing state for data frames */ |
| 462 | grpc_chttp2_data_parser data_parser; |
Craig Tiller | 3719f07 | 2015-06-12 17:19:51 -0700 | [diff] [blame] | 463 | /** reason give to rst_stream */ |
| 464 | gpr_uint32 rst_stream_reason; |
| 465 | /* amount of window given */ |
| 466 | gpr_uint64 outgoing_window_update; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 467 | |
Craig Tiller | 5dc3b30 | 2015-06-15 16:06:50 -0700 | [diff] [blame] | 468 | /** incoming metadata */ |
| 469 | grpc_chttp2_incoming_metadata_buffer incoming_metadata; |
| 470 | |
Craig Tiller | 9850510 | 2015-06-16 11:33:15 -0700 | [diff] [blame] | 471 | /* |
| 472 | grpc_linked_mdelem *incoming_metadata; |
| 473 | size_t incoming_metadata_count; |
| 474 | size_t incoming_metadata_capacity; |
| 475 | grpc_linked_mdelem *old_incoming_metadata; |
| 476 | gpr_timespec incoming_deadline; |
| 477 | */ |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 478 | }; |
| 479 | |
| 480 | struct grpc_chttp2_stream { |
| 481 | grpc_chttp2_stream_global global; |
| 482 | grpc_chttp2_stream_writing writing; |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 483 | grpc_chttp2_stream_parsing parsing; |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 484 | |
| 485 | grpc_chttp2_stream_link links[STREAM_LIST_COUNT]; |
| 486 | gpr_uint8 included[STREAM_LIST_COUNT]; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 487 | |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 488 | #if 0 |
| 489 | gpr_uint32 outgoing_window_update; |
| 490 | gpr_uint8 cancelled; |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 491 | |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 492 | grpc_stream_state callback_state; |
| 493 | grpc_stream_op_buffer callback_sopb; |
Craig Tiller | 606d874 | 2015-06-15 06:58:50 -0700 | [diff] [blame] | 494 | #endif |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 495 | }; |
| 496 | |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 497 | /** Transport writing call flow: |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 498 | chttp2_transport.c calls grpc_chttp2_unlocking_check_writes to see if writes |
| 499 | are required; |
| 500 | if they are, chttp2_transport.c calls grpc_chttp2_perform_writes to do the |
| 501 | writes. |
| 502 | Once writes have been completed (meaning another write could potentially be |
| 503 | started), |
| 504 | grpc_chttp2_terminate_writing is called. This will call |
| 505 | grpc_chttp2_cleanup_writing, at which |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 506 | point the write phase is complete. */ |
| 507 | |
Craig Tiller | 3208e39 | 2015-06-12 08:17:02 -0700 | [diff] [blame] | 508 | /** Someone is unlocking the transport mutex: check to see if writes |
| 509 | are required, and schedule them if so */ |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 510 | int grpc_chttp2_unlocking_check_writes(grpc_chttp2_transport_global *global, |
| 511 | grpc_chttp2_transport_writing *writing); |
| 512 | void grpc_chttp2_perform_writes( |
| 513 | grpc_chttp2_transport_writing *transport_writing, grpc_endpoint *endpoint); |
| 514 | void grpc_chttp2_terminate_writing( |
| 515 | grpc_chttp2_transport_writing *transport_writing, int success); |
| 516 | void grpc_chttp2_cleanup_writing(grpc_chttp2_transport_global *global, |
| 517 | grpc_chttp2_transport_writing *writing); |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 518 | |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 519 | void grpc_chttp2_prepare_to_read(grpc_chttp2_transport_global *global, |
| 520 | grpc_chttp2_transport_parsing *parsing); |
Craig Tiller | 1937b06 | 2015-06-16 08:47:38 -0700 | [diff] [blame] | 521 | /** Process one slice of incoming data */ |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 522 | int grpc_chttp2_perform_read(grpc_chttp2_transport_parsing *transport_parsing, |
| 523 | gpr_slice slice); |
| 524 | void grpc_chttp2_publish_reads(grpc_chttp2_transport_global *global, |
| 525 | grpc_chttp2_transport_parsing *parsing); |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 526 | |
| 527 | /** Get a writable stream |
| 528 | \return non-zero if there was a stream available */ |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 529 | void grpc_chttp2_list_add_writable_stream( |
| 530 | grpc_chttp2_transport_global *transport_global, |
| 531 | grpc_chttp2_stream_global *stream_global); |
| 532 | int grpc_chttp2_list_pop_writable_stream( |
| 533 | grpc_chttp2_transport_global *transport_global, |
| 534 | grpc_chttp2_transport_writing *transport_writing, |
| 535 | grpc_chttp2_stream_global **stream_global, |
| 536 | grpc_chttp2_stream_writing **stream_writing); |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 537 | |
Craig Tiller | cf1e319 | 2015-06-16 14:28:22 -0700 | [diff] [blame] | 538 | void grpc_chttp2_list_add_incoming_window_updated( |
| 539 | grpc_chttp2_transport_global *transport_global, |
| 540 | grpc_chttp2_stream_global *stream_global); |
| 541 | int grpc_chttp2_list_pop_incoming_window_updated( |
| 542 | grpc_chttp2_transport_global *transport_global, |
| 543 | grpc_chttp2_transport_parsing *transport_parsing, |
| 544 | grpc_chttp2_stream_global **stream_global, |
| 545 | grpc_chttp2_stream_parsing **stream_parsing); |
| 546 | |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 547 | void grpc_chttp2_list_add_writing_stream( |
| 548 | grpc_chttp2_transport_writing *transport_writing, |
| 549 | grpc_chttp2_stream_writing *stream_writing); |
| 550 | int grpc_chttp2_list_have_writing_streams( |
| 551 | grpc_chttp2_transport_writing *transport_writing); |
| 552 | int grpc_chttp2_list_pop_writing_stream( |
| 553 | grpc_chttp2_transport_writing *transport_writing, |
| 554 | grpc_chttp2_stream_writing **stream_writing); |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 555 | |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 556 | void grpc_chttp2_list_add_written_stream( |
| 557 | grpc_chttp2_transport_writing *transport_writing, |
| 558 | grpc_chttp2_stream_writing *stream_writing); |
| 559 | int grpc_chttp2_list_pop_written_stream( |
| 560 | grpc_chttp2_transport_global *transport_global, |
| 561 | grpc_chttp2_transport_writing *transport_writing, |
| 562 | grpc_chttp2_stream_global **stream_global, |
| 563 | grpc_chttp2_stream_writing **stream_writing); |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 564 | |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 565 | void grpc_chttp2_list_add_writable_window_update_stream( |
| 566 | grpc_chttp2_transport_global *transport_global, |
| 567 | grpc_chttp2_stream_global *stream_global); |
| 568 | int grpc_chttp2_list_pop_writable_window_update_stream( |
| 569 | grpc_chttp2_transport_global *transport_global, |
| 570 | grpc_chttp2_stream_global **stream_global); |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 571 | |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 572 | void grpc_chttp2_list_add_parsing_seen_stream( |
| 573 | grpc_chttp2_transport_parsing *transport_parsing, |
| 574 | grpc_chttp2_stream_parsing *stream_parsing); |
| 575 | int grpc_chttp2_list_pop_parsing_seen_stream( |
| 576 | grpc_chttp2_transport_global *transport_global, |
| 577 | grpc_chttp2_transport_parsing *transport_parsing, |
| 578 | grpc_chttp2_stream_global **stream_global, |
| 579 | grpc_chttp2_stream_parsing **stream_parsing); |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 580 | |
Craig Tiller | 5dc3b30 | 2015-06-15 16:06:50 -0700 | [diff] [blame] | 581 | void grpc_chttp2_list_add_waiting_for_concurrency( |
| 582 | grpc_chttp2_transport_global *transport_global, |
| 583 | grpc_chttp2_stream_global *stream_global); |
| 584 | int grpc_chttp2_list_pop_waiting_for_concurrency( |
| 585 | grpc_chttp2_transport_global *transport_global, |
| 586 | grpc_chttp2_stream_global **stream_global); |
| 587 | |
Craig Tiller | 83fb070 | 2015-06-16 21:13:07 -0700 | [diff] [blame^] | 588 | void grpc_chttp2_list_add_closed_waiting_for_parsing( |
Craig Tiller | 5dc3b30 | 2015-06-15 16:06:50 -0700 | [diff] [blame] | 589 | grpc_chttp2_transport_global *transport_global, |
| 590 | grpc_chttp2_stream_global *stream_global); |
Craig Tiller | 83fb070 | 2015-06-16 21:13:07 -0700 | [diff] [blame^] | 591 | int grpc_chttp2_list_pop_closed_waiting_for_parsing( |
Craig Tiller | 5dc3b30 | 2015-06-15 16:06:50 -0700 | [diff] [blame] | 592 | grpc_chttp2_transport_global *transport_global, |
| 593 | grpc_chttp2_stream_global **stream_global); |
| 594 | |
Craig Tiller | 6459db4 | 2015-06-15 17:11:45 -0700 | [diff] [blame] | 595 | void grpc_chttp2_list_add_read_write_state_changed( |
| 596 | grpc_chttp2_transport_global *transport_global, |
| 597 | grpc_chttp2_stream_global *stream_global); |
Craig Tiller | f73fcd1 | 2015-06-16 16:25:26 -0700 | [diff] [blame] | 598 | int grpc_chttp2_list_pop_read_write_state_changed( |
| 599 | grpc_chttp2_transport_global *transport_global, |
| 600 | grpc_chttp2_stream_global **stream_global); |
Craig Tiller | 6459db4 | 2015-06-15 17:11:45 -0700 | [diff] [blame] | 601 | |
| 602 | void grpc_chttp2_list_add_incoming_window_state_changed( |
| 603 | grpc_chttp2_transport_global *transport_global, |
| 604 | grpc_chttp2_stream_global *stream_global); |
| 605 | |
Craig Tiller | 1937b06 | 2015-06-16 08:47:38 -0700 | [diff] [blame] | 606 | /** schedule a closure to run without the transport lock taken */ |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 607 | void grpc_chttp2_schedule_closure( |
| 608 | grpc_chttp2_transport_global *transport_global, grpc_iomgr_closure *closure, |
| 609 | int success); |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 610 | |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 611 | grpc_chttp2_stream_parsing *grpc_chttp2_parsing_lookup_stream( |
| 612 | grpc_chttp2_transport_parsing *transport_parsing, gpr_uint32 id); |
Craig Tiller | 83fb070 | 2015-06-16 21:13:07 -0700 | [diff] [blame^] | 613 | void grpc_chttp2_parsing_remove_stream( |
| 614 | grpc_chttp2_transport_parsing *transport_parsing, gpr_uint32 id); |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 615 | grpc_chttp2_stream_parsing *grpc_chttp2_parsing_accept_stream( |
| 616 | grpc_chttp2_transport_parsing *transport_parsing, gpr_uint32 id); |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 617 | |
Craig Tiller | 9850510 | 2015-06-16 11:33:15 -0700 | [diff] [blame] | 618 | void grpc_chttp2_add_incoming_goaway( |
| 619 | grpc_chttp2_transport_global *transport_global, gpr_uint32 goaway_error, |
| 620 | gpr_slice goaway_text); |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 621 | |
Craig Tiller | 9850510 | 2015-06-16 11:33:15 -0700 | [diff] [blame] | 622 | void grpc_chttp2_remove_from_stream_map( |
| 623 | grpc_chttp2_transport_global *transport_global, |
| 624 | grpc_chttp2_stream_global *stream_global); |
Craig Tiller | 5dc3b30 | 2015-06-15 16:06:50 -0700 | [diff] [blame] | 625 | |
Craig Tiller | 9850510 | 2015-06-16 11:33:15 -0700 | [diff] [blame] | 626 | void grpc_chttp2_register_stream(grpc_chttp2_transport *t, |
| 627 | grpc_chttp2_stream *s); |
| 628 | void grpc_chttp2_unregister_stream(grpc_chttp2_transport *t, |
| 629 | grpc_chttp2_stream *s); |
| 630 | void grpc_chttp2_for_all_streams( |
| 631 | grpc_chttp2_transport_global *transport_global, void *user_data, |
| 632 | void (*cb)(grpc_chttp2_transport_global *transport_global, void *user_data, |
| 633 | grpc_chttp2_stream_global *stream_global)); |
Craig Tiller | 5dc3b30 | 2015-06-15 16:06:50 -0700 | [diff] [blame] | 634 | |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 635 | #define GRPC_CHTTP2_CLIENT_CONNECT_STRING "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" |
Craig Tiller | 4aa71a1 | 2015-06-15 13:00:55 -0700 | [diff] [blame] | 636 | #define GRPC_CHTTP2_CLIENT_CONNECT_STRLEN \ |
| 637 | (sizeof(GRPC_CHTTP2_CLIENT_CONNECT_STRING) - 1) |
Craig Tiller | d20efd2 | 2015-06-12 16:17:09 -0700 | [diff] [blame] | 638 | |
| 639 | extern int grpc_http_trace; |
| 640 | |
| 641 | #define IF_TRACING(stmt) \ |
| 642 | if (!(grpc_http_trace)) \ |
| 643 | ; \ |
| 644 | else \ |
| 645 | stmt |
Craig Tiller | 3208e39 | 2015-06-12 08:17:02 -0700 | [diff] [blame] | 646 | |
Craig Tiller | 9b8671c | 2015-06-12 07:41:54 -0700 | [diff] [blame] | 647 | #endif |