aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/transport/chttp2
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2016-01-08 12:33:22 -0800
committerGravatar murgatroid99 <mlumish@google.com>2016-01-08 12:33:22 -0800
commit8b791a4a7f784fb367af6e56c2596c578e974338 (patch)
treeab7baa05c08aeac191768fadc766866434beb36b /src/core/transport/chttp2
parentc357749b48720e00bce57c26acb2195047d63263 (diff)
parentb47eab53dec9a6d811ad26e0873dc7ec1bac7d46 (diff)
Merged from master and resolved merge conflicts
Diffstat (limited to 'src/core/transport/chttp2')
-rw-r--r--src/core/transport/chttp2/bin_encoder.c58
-rw-r--r--src/core/transport/chttp2/frame_data.c55
-rw-r--r--src/core/transport/chttp2/frame_data.h12
-rw-r--r--src/core/transport/chttp2/frame_goaway.c60
-rw-r--r--src/core/transport/chttp2/frame_goaway.h12
-rw-r--r--src/core/transport/chttp2/frame_ping.c12
-rw-r--r--src/core/transport/chttp2/frame_ping.h10
-rw-r--r--src/core/transport/chttp2/frame_rst_stream.c37
-rw-r--r--src/core/transport/chttp2/frame_rst_stream.h8
-rw-r--r--src/core/transport/chttp2/frame_settings.c60
-rw-r--r--src/core/transport/chttp2/frame_settings.h26
-rw-r--r--src/core/transport/chttp2/frame_window_update.c35
-rw-r--r--src/core/transport/chttp2/frame_window_update.h12
-rw-r--r--src/core/transport/chttp2/hpack_encoder.c142
-rw-r--r--src/core/transport/chttp2/hpack_encoder.h32
-rw-r--r--src/core/transport/chttp2/hpack_parser.c334
-rw-r--r--src/core/transport/chttp2/hpack_parser.h32
-rw-r--r--src/core/transport/chttp2/hpack_table.c26
-rw-r--r--src/core/transport/chttp2/hpack_table.h22
-rw-r--r--src/core/transport/chttp2/internal.h166
-rw-r--r--src/core/transport/chttp2/parsing.c50
-rw-r--r--src/core/transport/chttp2/stream_lists.c8
-rw-r--r--src/core/transport/chttp2/stream_map.c27
-rw-r--r--src/core/transport/chttp2/stream_map.h13
-rw-r--r--src/core/transport/chttp2/timeout_encoding.c22
-rw-r--r--src/core/transport/chttp2/varint.c17
-rw-r--r--src/core/transport/chttp2/varint.h15
-rw-r--r--src/core/transport/chttp2/writing.c30
28 files changed, 668 insertions, 665 deletions
diff --git a/src/core/transport/chttp2/bin_encoder.c b/src/core/transport/chttp2/bin_encoder.c
index 53ea9ac609..f26bc7e29b 100644
--- a/src/core/transport/chttp2/bin_encoder.c
+++ b/src/core/transport/chttp2/bin_encoder.c
@@ -42,8 +42,8 @@ static const char alphabet[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
typedef struct {
- gpr_uint16 bits;
- gpr_uint8 length;
+ uint16_t bits;
+ uint8_t length;
} b64_huff_sym;
static const b64_huff_sym huff_alphabet[64] = {{0x21, 6},
@@ -111,7 +111,7 @@ static const b64_huff_sym huff_alphabet[64] = {{0x21, 6},
{0x7fb, 11},
{0x18, 6}};
-static const gpr_uint8 tail_xtra[3] = {0, 2, 3};
+static const uint8_t tail_xtra[3] = {0, 2, 3};
gpr_slice grpc_chttp2_base64_encode(gpr_slice input) {
size_t input_length = GPR_SLICE_LENGTH(input);
@@ -119,7 +119,7 @@ gpr_slice grpc_chttp2_base64_encode(gpr_slice input) {
size_t tail_case = input_length % 3;
size_t output_length = input_triplets * 4 + tail_xtra[tail_case];
gpr_slice output = gpr_slice_malloc(output_length);
- gpr_uint8 *in = GPR_SLICE_START_PTR(input);
+ uint8_t *in = GPR_SLICE_START_PTR(input);
char *out = (char *)GPR_SLICE_START_PTR(output);
size_t i;
@@ -159,11 +159,11 @@ gpr_slice grpc_chttp2_base64_encode(gpr_slice input) {
gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) {
size_t nbits;
- gpr_uint8 *in;
- gpr_uint8 *out;
+ uint8_t *in;
+ uint8_t *out;
gpr_slice output;
- gpr_uint32 temp = 0;
- gpr_uint32 temp_length = 0;
+ uint32_t temp = 0;
+ uint32_t temp_length = 0;
nbits = 0;
for (in = GPR_SLICE_START_PTR(input); in != GPR_SLICE_END_PTR(input); ++in) {
@@ -180,7 +180,7 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) {
while (temp_length > 8) {
temp_length -= 8;
- *out++ = (gpr_uint8)(temp >> temp_length);
+ *out++ = (uint8_t)(temp >> temp_length);
}
}
@@ -189,8 +189,8 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) {
* expanded form due to the "integral promotion" performed (see section
* 3.2.1.1 of the C89 draft standard). A cast to the smaller container type
* is then required to avoid the compiler warning */
- *out++ = (gpr_uint8)((gpr_uint8)(temp << (8u - temp_length)) |
- (gpr_uint8)(0xffu >> temp_length));
+ *out++ = (uint8_t)((uint8_t)(temp << (8u - temp_length)) |
+ (uint8_t)(0xffu >> temp_length));
}
GPR_ASSERT(out == GPR_SLICE_END_PTR(output));
@@ -199,28 +199,28 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) {
}
typedef struct {
- gpr_uint32 temp;
- gpr_uint32 temp_length;
- gpr_uint8 *out;
+ uint32_t temp;
+ uint32_t temp_length;
+ uint8_t *out;
} huff_out;
static void enc_flush_some(huff_out *out) {
while (out->temp_length > 8) {
out->temp_length -= 8;
- *out->out++ = (gpr_uint8)(out->temp >> out->temp_length);
+ *out->out++ = (uint8_t)(out->temp >> out->temp_length);
}
}
-static void enc_add2(huff_out *out, gpr_uint8 a, gpr_uint8 b) {
+static void enc_add2(huff_out *out, uint8_t a, uint8_t b) {
b64_huff_sym sa = huff_alphabet[a];
b64_huff_sym sb = huff_alphabet[b];
out->temp = (out->temp << (sa.length + sb.length)) |
- ((gpr_uint32)sa.bits << sb.length) | sb.bits;
- out->temp_length += (gpr_uint32)sa.length + (gpr_uint32)sb.length;
+ ((uint32_t)sa.bits << sb.length) | sb.bits;
+ out->temp_length += (uint32_t)sa.length + (uint32_t)sb.length;
enc_flush_some(out);
}
-static void enc_add1(huff_out *out, gpr_uint8 a) {
+static void enc_add1(huff_out *out, uint8_t a) {
b64_huff_sym sa = huff_alphabet[a];
out->temp = (out->temp << sa.length) | sa.bits;
out->temp_length += sa.length;
@@ -235,8 +235,8 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) {
size_t max_output_bits = 11 * output_syms;
size_t max_output_length = max_output_bits / 8 + (max_output_bits % 8 != 0);
gpr_slice output = gpr_slice_malloc(max_output_length);
- gpr_uint8 *in = GPR_SLICE_START_PTR(input);
- gpr_uint8 *start_out = GPR_SLICE_START_PTR(output);
+ uint8_t *in = GPR_SLICE_START_PTR(input);
+ uint8_t *start_out = GPR_SLICE_START_PTR(output);
huff_out out;
size_t i;
@@ -246,9 +246,9 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) {
/* encode full triplets */
for (i = 0; i < input_triplets; i++) {
- enc_add2(&out, in[0] >> 2, (gpr_uint8)((in[0] & 0x3) << 4) | (in[1] >> 4));
- enc_add2(&out, (gpr_uint8)((in[1] & 0xf) << 2) | (in[2] >> 6),
- (gpr_uint8)(in[2] & 0x3f));
+ enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4) | (in[1] >> 4));
+ enc_add2(&out, (uint8_t)((in[1] & 0xf) << 2) | (in[2] >> 6),
+ (uint8_t)(in[2] & 0x3f));
in += 3;
}
@@ -257,13 +257,13 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) {
case 0:
break;
case 1:
- enc_add2(&out, in[0] >> 2, (gpr_uint8)((in[0] & 0x3) << 4));
+ enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4));
in += 1;
break;
case 2:
enc_add2(&out, in[0] >> 2,
- (gpr_uint8)((in[0] & 0x3) << 4) | (gpr_uint8)(in[1] >> 4));
- enc_add1(&out, (gpr_uint8)((in[1] & 0xf) << 2));
+ (uint8_t)((in[0] & 0x3) << 4) | (uint8_t)(in[1] >> 4));
+ enc_add1(&out, (uint8_t)((in[1] & 0xf) << 2));
in += 2;
break;
}
@@ -273,8 +273,8 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) {
* expanded form due to the "integral promotion" performed (see section
* 3.2.1.1 of the C89 draft standard). A cast to the smaller container type
* is then required to avoid the compiler warning */
- *out.out++ = (gpr_uint8)((gpr_uint8)(out.temp << (8u - out.temp_length)) |
- (gpr_uint8)(0xffu >> out.temp_length));
+ *out.out++ = (uint8_t)((uint8_t)(out.temp << (8u - out.temp_length)) |
+ (uint8_t)(0xffu >> out.temp_length));
}
GPR_ASSERT(out.out <= GPR_SLICE_END_PTR(output));
diff --git a/src/core/transport/chttp2/frame_data.c b/src/core/transport/chttp2/frame_data.c
index 732124b7c9..f9a1af8873 100644
--- a/src/core/transport/chttp2/frame_data.c
+++ b/src/core/transport/chttp2/frame_data.c
@@ -53,16 +53,17 @@ void grpc_chttp2_data_parser_destroy(grpc_exec_ctx *exec_ctx,
grpc_chttp2_data_parser *parser) {
grpc_byte_stream *bs;
if (parser->parsing_frame) {
- grpc_chttp2_incoming_byte_stream_finished(exec_ctx, parser->parsing_frame);
+ grpc_chttp2_incoming_byte_stream_finished(exec_ctx, parser->parsing_frame,
+ 0, 1);
}
while (
(bs = grpc_chttp2_incoming_frame_queue_pop(&parser->incoming_frames))) {
- grpc_byte_stream_destroy(bs);
+ grpc_byte_stream_destroy(exec_ctx, bs);
}
}
grpc_chttp2_parse_error grpc_chttp2_data_parser_begin_frame(
- grpc_chttp2_data_parser *parser, gpr_uint8 flags) {
+ grpc_chttp2_data_parser *parser, uint8_t flags) {
if (flags & ~GRPC_CHTTP2_DATA_FLAG_END_STREAM) {
gpr_log(GPR_ERROR, "unsupported data flags: 0x%02x", flags);
return GRPC_CHTTP2_STREAM_ERROR;
@@ -110,24 +111,24 @@ grpc_byte_stream *grpc_chttp2_incoming_frame_queue_pop(
return out;
}
-void grpc_chttp2_encode_data(gpr_uint32 id, gpr_slice_buffer *inbuf,
- gpr_uint32 write_bytes, int is_eof,
+void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf,
+ uint32_t write_bytes, int is_eof,
gpr_slice_buffer *outbuf) {
gpr_slice hdr;
- gpr_uint8 *p;
+ uint8_t *p;
hdr = gpr_slice_malloc(9);
p = GPR_SLICE_START_PTR(hdr);
GPR_ASSERT(write_bytes < (1 << 24));
- *p++ = (gpr_uint8)(write_bytes >> 16);
- *p++ = (gpr_uint8)(write_bytes >> 8);
- *p++ = (gpr_uint8)(write_bytes);
+ *p++ = (uint8_t)(write_bytes >> 16);
+ *p++ = (uint8_t)(write_bytes >> 8);
+ *p++ = (uint8_t)(write_bytes);
*p++ = GRPC_CHTTP2_FRAME_DATA;
*p++ = is_eof ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0;
- *p++ = (gpr_uint8)(id >> 24);
- *p++ = (gpr_uint8)(id >> 16);
- *p++ = (gpr_uint8)(id >> 8);
- *p++ = (gpr_uint8)(id);
+ *p++ = (uint8_t)(id >> 24);
+ *p++ = (uint8_t)(id >> 16);
+ *p++ = (uint8_t)(id >> 8);
+ *p++ = (uint8_t)(id);
gpr_slice_buffer_add(outbuf, hdr);
gpr_slice_buffer_move_first(inbuf, write_bytes, outbuf);
@@ -137,11 +138,11 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
- gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
- gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
- gpr_uint8 *cur = beg;
+ uint8_t *const beg = GPR_SLICE_START_PTR(slice);
+ uint8_t *const end = GPR_SLICE_END_PTR(slice);
+ uint8_t *cur = beg;
grpc_chttp2_data_parser *p = parser;
- gpr_uint32 message_flags;
+ uint32_t message_flags;
grpc_chttp2_incoming_byte_stream *incoming_byte_stream;
if (is_last && p->is_last_frame) {
@@ -173,28 +174,28 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
}
/* fallthrough */
case GRPC_CHTTP2_DATA_FH_1:
- p->frame_size = ((gpr_uint32)*cur) << 24;
+ p->frame_size = ((uint32_t)*cur) << 24;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_2;
return GRPC_CHTTP2_PARSE_OK;
}
/* fallthrough */
case GRPC_CHTTP2_DATA_FH_2:
- p->frame_size |= ((gpr_uint32)*cur) << 16;
+ p->frame_size |= ((uint32_t)*cur) << 16;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_3;
return GRPC_CHTTP2_PARSE_OK;
}
/* fallthrough */
case GRPC_CHTTP2_DATA_FH_3:
- p->frame_size |= ((gpr_uint32)*cur) << 8;
+ p->frame_size |= ((uint32_t)*cur) << 8;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_4;
return GRPC_CHTTP2_PARSE_OK;
}
/* fallthrough */
case GRPC_CHTTP2_DATA_FH_4:
- p->frame_size |= ((gpr_uint32)*cur);
+ p->frame_size |= ((uint32_t)*cur);
p->state = GRPC_CHTTP2_DATA_FRAME;
++cur;
message_flags = 0;
@@ -214,20 +215,22 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
}
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
stream_parsing);
- if ((gpr_uint32)(end - cur) == p->frame_size) {
+ if ((uint32_t)(end - cur) == p->frame_size) {
grpc_chttp2_incoming_byte_stream_push(
exec_ctx, p->parsing_frame,
gpr_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
- grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame);
+ grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame, 1,
+ 1);
p->parsing_frame = NULL;
p->state = GRPC_CHTTP2_DATA_FH_0;
return GRPC_CHTTP2_PARSE_OK;
- } else if ((gpr_uint32)(end - cur) > p->frame_size) {
+ } else if ((uint32_t)(end - cur) > p->frame_size) {
grpc_chttp2_incoming_byte_stream_push(
exec_ctx, p->parsing_frame,
gpr_slice_sub(slice, (size_t)(cur - beg),
(size_t)(cur + p->frame_size - beg)));
- grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame);
+ grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame, 1,
+ 1);
p->parsing_frame = NULL;
cur += p->frame_size;
goto fh_0; /* loop */
@@ -236,7 +239,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
exec_ctx, p->parsing_frame,
gpr_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
GPR_ASSERT((size_t)(end - cur) <= p->frame_size);
- p->frame_size -= (gpr_uint32)(end - cur);
+ p->frame_size -= (uint32_t)(end - cur);
return GRPC_CHTTP2_PARSE_OK;
}
}
diff --git a/src/core/transport/chttp2/frame_data.h b/src/core/transport/chttp2/frame_data.h
index 27d4d0043b..936b7a2589 100644
--- a/src/core/transport/chttp2/frame_data.h
+++ b/src/core/transport/chttp2/frame_data.h
@@ -61,9 +61,9 @@ typedef struct grpc_chttp2_incoming_frame_queue {
typedef struct {
grpc_chttp2_stream_state state;
- gpr_uint8 is_last_frame;
- gpr_uint8 frame_type;
- gpr_uint32 frame_size;
+ uint8_t is_last_frame;
+ uint8_t frame_type;
+ uint32_t frame_size;
int is_frame_compressed;
grpc_chttp2_incoming_frame_queue incoming_frames;
@@ -85,7 +85,7 @@ void grpc_chttp2_data_parser_destroy(grpc_exec_ctx *exec_ctx,
/* start processing a new data frame */
grpc_chttp2_parse_error grpc_chttp2_data_parser_begin_frame(
- grpc_chttp2_data_parser *parser, gpr_uint8 flags);
+ grpc_chttp2_data_parser *parser, uint8_t flags);
/* handle a slice of a data frame - is_last indicates the last slice of a
frame */
@@ -94,8 +94,8 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
-void grpc_chttp2_encode_data(gpr_uint32 id, gpr_slice_buffer *inbuf,
- gpr_uint32 write_bytes, int is_eof,
+void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf,
+ uint32_t write_bytes, int is_eof,
gpr_slice_buffer *outbuf);
#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_DATA_H */
diff --git a/src/core/transport/chttp2/frame_goaway.c b/src/core/transport/chttp2/frame_goaway.c
index c5758bcb71..2fa525e989 100644
--- a/src/core/transport/chttp2/frame_goaway.c
+++ b/src/core/transport/chttp2/frame_goaway.c
@@ -48,7 +48,7 @@ void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser *p) {
}
grpc_chttp2_parse_error grpc_chttp2_goaway_parser_begin_frame(
- grpc_chttp2_goaway_parser *p, gpr_uint32 length, gpr_uint8 flags) {
+ grpc_chttp2_goaway_parser *p, uint32_t length, uint8_t flags) {
if (length < 8) {
gpr_log(GPR_ERROR, "goaway frame too short (%d bytes)", length);
return GRPC_CHTTP2_CONNECTION_ERROR;
@@ -66,9 +66,9 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
- gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
- gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
- gpr_uint8 *cur = beg;
+ uint8_t *const beg = GPR_SLICE_START_PTR(slice);
+ uint8_t *const end = GPR_SLICE_END_PTR(slice);
+ uint8_t *cur = beg;
grpc_chttp2_goaway_parser *p = parser;
switch (p->state) {
@@ -77,7 +77,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_LSI0;
return GRPC_CHTTP2_PARSE_OK;
}
- p->last_stream_id = ((gpr_uint32)*cur) << 24;
+ p->last_stream_id = ((uint32_t)*cur) << 24;
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_LSI1:
@@ -85,7 +85,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_LSI1;
return GRPC_CHTTP2_PARSE_OK;
}
- p->last_stream_id |= ((gpr_uint32)*cur) << 16;
+ p->last_stream_id |= ((uint32_t)*cur) << 16;
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_LSI2:
@@ -93,7 +93,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_LSI2;
return GRPC_CHTTP2_PARSE_OK;
}
- p->last_stream_id |= ((gpr_uint32)*cur) << 8;
+ p->last_stream_id |= ((uint32_t)*cur) << 8;
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_LSI3:
@@ -101,7 +101,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_LSI3;
return GRPC_CHTTP2_PARSE_OK;
}
- p->last_stream_id |= ((gpr_uint32)*cur);
+ p->last_stream_id |= ((uint32_t)*cur);
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_ERR0:
@@ -109,7 +109,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_ERR0;
return GRPC_CHTTP2_PARSE_OK;
}
- p->error_code = ((gpr_uint32)*cur) << 24;
+ p->error_code = ((uint32_t)*cur) << 24;
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_ERR1:
@@ -117,7 +117,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_ERR1;
return GRPC_CHTTP2_PARSE_OK;
}
- p->error_code |= ((gpr_uint32)*cur) << 16;
+ p->error_code |= ((uint32_t)*cur) << 16;
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_ERR2:
@@ -125,7 +125,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_ERR2;
return GRPC_CHTTP2_PARSE_OK;
}
- p->error_code |= ((gpr_uint32)*cur) << 8;
+ p->error_code |= ((uint32_t)*cur) << 8;
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_ERR3:
@@ -133,13 +133,13 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_ERR3;
return GRPC_CHTTP2_PARSE_OK;
}
- p->error_code |= ((gpr_uint32)*cur);
+ p->error_code |= ((uint32_t)*cur);
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_DEBUG:
memcpy(p->debug_data + p->debug_pos, cur, (size_t)(end - cur));
- GPR_ASSERT((size_t)(end - cur) < GPR_UINT32_MAX - p->debug_pos);
- p->debug_pos += (gpr_uint32)(end - cur);
+ GPR_ASSERT((size_t)(end - cur) < UINT32_MAX - p->debug_pos);
+ p->debug_pos += (uint32_t)(end - cur);
p->state = GRPC_CHTTP2_GOAWAY_DEBUG;
if (is_last) {
transport_parsing->goaway_received = 1;
@@ -155,19 +155,19 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
GPR_UNREACHABLE_CODE(return GRPC_CHTTP2_CONNECTION_ERROR);
}
-void grpc_chttp2_goaway_append(gpr_uint32 last_stream_id, gpr_uint32 error_code,
+void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
gpr_slice debug_data,
gpr_slice_buffer *slice_buffer) {
gpr_slice header = gpr_slice_malloc(9 + 4 + 4);
- gpr_uint8 *p = GPR_SLICE_START_PTR(header);
- gpr_uint32 frame_length;
- GPR_ASSERT(GPR_SLICE_LENGTH(debug_data) < GPR_UINT32_MAX - 4 - 4);
- frame_length = 4 + 4 + (gpr_uint32)GPR_SLICE_LENGTH(debug_data);
+ uint8_t *p = GPR_SLICE_START_PTR(header);
+ uint32_t frame_length;
+ GPR_ASSERT(GPR_SLICE_LENGTH(debug_data) < UINT32_MAX - 4 - 4);
+ frame_length = 4 + 4 + (uint32_t)GPR_SLICE_LENGTH(debug_data);
/* frame header: length */
- *p++ = (gpr_uint8)(frame_length >> 16);
- *p++ = (gpr_uint8)(frame_length >> 8);
- *p++ = (gpr_uint8)(frame_length);
+ *p++ = (uint8_t)(frame_length >> 16);
+ *p++ = (uint8_t)(frame_length >> 8);
+ *p++ = (uint8_t)(frame_length);
/* frame header: type */
*p++ = GRPC_CHTTP2_FRAME_GOAWAY;
/* frame header: flags */
@@ -178,15 +178,15 @@ void grpc_chttp2_goaway_append(gpr_uint32 last_stream_id, gpr_uint32 error_code,
*p++ = 0;
*p++ = 0;
/* payload: last stream id */
- *p++ = (gpr_uint8)(last_stream_id >> 24);
- *p++ = (gpr_uint8)(last_stream_id >> 16);
- *p++ = (gpr_uint8)(last_stream_id >> 8);
- *p++ = (gpr_uint8)(last_stream_id);
+ *p++ = (uint8_t)(last_stream_id >> 24);
+ *p++ = (uint8_t)(last_stream_id >> 16);
+ *p++ = (uint8_t)(last_stream_id >> 8);
+ *p++ = (uint8_t)(last_stream_id);
/* payload: error code */
- *p++ = (gpr_uint8)(error_code >> 24);
- *p++ = (gpr_uint8)(error_code >> 16);
- *p++ = (gpr_uint8)(error_code >> 8);
- *p++ = (gpr_uint8)(error_code);
+ *p++ = (uint8_t)(error_code >> 24);
+ *p++ = (uint8_t)(error_code >> 16);
+ *p++ = (uint8_t)(error_code >> 8);
+ *p++ = (uint8_t)(error_code);
GPR_ASSERT(p == GPR_SLICE_END_PTR(header));
gpr_slice_buffer_add(slice_buffer, header);
gpr_slice_buffer_add(slice_buffer, debug_data);
diff --git a/src/core/transport/chttp2/frame_goaway.h b/src/core/transport/chttp2/frame_goaway.h
index 06aaa92f07..e1a72b4013 100644
--- a/src/core/transport/chttp2/frame_goaway.h
+++ b/src/core/transport/chttp2/frame_goaway.h
@@ -54,23 +54,23 @@ typedef enum {
typedef struct {
grpc_chttp2_goaway_parse_state state;
- gpr_uint32 last_stream_id;
- gpr_uint32 error_code;
+ uint32_t last_stream_id;
+ uint32_t error_code;
char *debug_data;
- gpr_uint32 debug_length;
- gpr_uint32 debug_pos;
+ uint32_t debug_length;
+ uint32_t debug_pos;
} grpc_chttp2_goaway_parser;
void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser *p);
void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser *p);
grpc_chttp2_parse_error grpc_chttp2_goaway_parser_begin_frame(
- grpc_chttp2_goaway_parser *parser, gpr_uint32 length, gpr_uint8 flags);
+ grpc_chttp2_goaway_parser *parser, uint32_t length, uint8_t flags);
grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
-void grpc_chttp2_goaway_append(gpr_uint32 last_stream_id, gpr_uint32 error_code,
+void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
gpr_slice debug_data,
gpr_slice_buffer *slice_buffer);
diff --git a/src/core/transport/chttp2/frame_ping.c b/src/core/transport/chttp2/frame_ping.c
index 8e763278ff..c6ab522283 100644
--- a/src/core/transport/chttp2/frame_ping.c
+++ b/src/core/transport/chttp2/frame_ping.c
@@ -39,9 +39,9 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-gpr_slice grpc_chttp2_ping_create(gpr_uint8 ack, gpr_uint8 *opaque_8bytes) {
+gpr_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes) {
gpr_slice slice = gpr_slice_malloc(9 + 8);
- gpr_uint8 *p = GPR_SLICE_START_PTR(slice);
+ uint8_t *p = GPR_SLICE_START_PTR(slice);
*p++ = 0;
*p++ = 0;
@@ -58,7 +58,7 @@ gpr_slice grpc_chttp2_ping_create(gpr_uint8 ack, gpr_uint8 *opaque_8bytes) {
}
grpc_chttp2_parse_error grpc_chttp2_ping_parser_begin_frame(
- grpc_chttp2_ping_parser *parser, gpr_uint32 length, gpr_uint8 flags) {
+ grpc_chttp2_ping_parser *parser, uint32_t length, uint8_t flags) {
if (flags & 0xfe || length != 8) {
gpr_log(GPR_ERROR, "invalid ping: length=%d, flags=%02x", length, flags);
return GRPC_CHTTP2_CONNECTION_ERROR;
@@ -72,9 +72,9 @@ grpc_chttp2_parse_error grpc_chttp2_ping_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
- gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
- gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
- gpr_uint8 *cur = beg;
+ uint8_t *const beg = GPR_SLICE_START_PTR(slice);
+ uint8_t *const end = GPR_SLICE_END_PTR(slice);
+ uint8_t *cur = beg;
grpc_chttp2_ping_parser *p = parser;
while (p->byte != 8 && cur != end) {
diff --git a/src/core/transport/chttp2/frame_ping.h b/src/core/transport/chttp2/frame_ping.h
index 2c71d0d491..16d7a72618 100644
--- a/src/core/transport/chttp2/frame_ping.h
+++ b/src/core/transport/chttp2/frame_ping.h
@@ -39,15 +39,15 @@
#include "src/core/transport/chttp2/frame.h"
typedef struct {
- gpr_uint8 byte;
- gpr_uint8 is_ack;
- gpr_uint8 opaque_8bytes[8];
+ uint8_t byte;
+ uint8_t is_ack;
+ uint8_t opaque_8bytes[8];
} grpc_chttp2_ping_parser;
-gpr_slice grpc_chttp2_ping_create(gpr_uint8 ack, gpr_uint8 *opaque_8bytes);
+gpr_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes);
grpc_chttp2_parse_error grpc_chttp2_ping_parser_begin_frame(
- grpc_chttp2_ping_parser *parser, gpr_uint32 length, gpr_uint8 flags);
+ grpc_chttp2_ping_parser *parser, uint32_t length, uint8_t flags);
grpc_chttp2_parse_error grpc_chttp2_ping_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
diff --git a/src/core/transport/chttp2/frame_rst_stream.c b/src/core/transport/chttp2/frame_rst_stream.c
index 3cd5bcfc39..754529e4b9 100644
--- a/src/core/transport/chttp2/frame_rst_stream.c
+++ b/src/core/transport/chttp2/frame_rst_stream.c
@@ -38,29 +38,29 @@
#include "src/core/transport/chttp2/frame.h"
-gpr_slice grpc_chttp2_rst_stream_create(gpr_uint32 id, gpr_uint32 code) {
+gpr_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code) {
gpr_slice slice = gpr_slice_malloc(13);
- gpr_uint8 *p = GPR_SLICE_START_PTR(slice);
+ uint8_t *p = GPR_SLICE_START_PTR(slice);
*p++ = 0;
*p++ = 0;
*p++ = 4;
*p++ = GRPC_CHTTP2_FRAME_RST_STREAM;
*p++ = 0;
- *p++ = (gpr_uint8)(id >> 24);
- *p++ = (gpr_uint8)(id >> 16);
- *p++ = (gpr_uint8)(id >> 8);
- *p++ = (gpr_uint8)(id);
- *p++ = (gpr_uint8)(code >> 24);
- *p++ = (gpr_uint8)(code >> 16);
- *p++ = (gpr_uint8)(code >> 8);
- *p++ = (gpr_uint8)(code);
+ *p++ = (uint8_t)(id >> 24);
+ *p++ = (uint8_t)(id >> 16);
+ *p++ = (uint8_t)(id >> 8);
+ *p++ = (uint8_t)(id);
+ *p++ = (uint8_t)(code >> 24);
+ *p++ = (uint8_t)(code >> 16);
+ *p++ = (uint8_t)(code >> 8);
+ *p++ = (uint8_t)(code);
return slice;
}
grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_begin_frame(
- grpc_chttp2_rst_stream_parser *parser, gpr_uint32 length, gpr_uint8 flags) {
+ grpc_chttp2_rst_stream_parser *parser, uint32_t length, uint8_t flags) {
if (length != 4) {
gpr_log(GPR_ERROR, "invalid rst_stream: length=%d, flags=%02x", length,
flags);
@@ -74,9 +74,9 @@ grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
- gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
- gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
- gpr_uint8 *cur = beg;
+ uint8_t *const beg = GPR_SLICE_START_PTR(slice);
+ uint8_t *const end = GPR_SLICE_END_PTR(slice);
+ uint8_t *cur = beg;
grpc_chttp2_rst_stream_parser *p = parser;
while (p->byte != 4 && cur != end) {
@@ -89,11 +89,10 @@ grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse(
GPR_ASSERT(is_last);
stream_parsing->received_close = 1;
stream_parsing->saw_rst_stream = 1;
- stream_parsing->rst_stream_reason =
- (((gpr_uint32)p->reason_bytes[0]) << 24) |
- (((gpr_uint32)p->reason_bytes[1]) << 16) |
- (((gpr_uint32)p->reason_bytes[2]) << 8) |
- (((gpr_uint32)p->reason_bytes[3]));
+ stream_parsing->rst_stream_reason = (((uint32_t)p->reason_bytes[0]) << 24) |
+ (((uint32_t)p->reason_bytes[1]) << 16) |
+ (((uint32_t)p->reason_bytes[2]) << 8) |
+ (((uint32_t)p->reason_bytes[3]));
}
return GRPC_CHTTP2_PARSE_OK;
diff --git a/src/core/transport/chttp2/frame_rst_stream.h b/src/core/transport/chttp2/frame_rst_stream.h
index 92cb77c971..72ca654c32 100644
--- a/src/core/transport/chttp2/frame_rst_stream.h
+++ b/src/core/transport/chttp2/frame_rst_stream.h
@@ -39,14 +39,14 @@
#include "src/core/iomgr/exec_ctx.h"
typedef struct {
- gpr_uint8 byte;
- gpr_uint8 reason_bytes[4];
+ uint8_t byte;
+ uint8_t reason_bytes[4];
} grpc_chttp2_rst_stream_parser;
-gpr_slice grpc_chttp2_rst_stream_create(gpr_uint32 stream_id, gpr_uint32 code);
+gpr_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code);
grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_begin_frame(
- grpc_chttp2_rst_stream_parser *parser, gpr_uint32 length, gpr_uint8 flags);
+ grpc_chttp2_rst_stream_parser *parser, uint32_t length, uint8_t flags);
grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
diff --git a/src/core/transport/chttp2/frame_settings.c b/src/core/transport/chttp2/frame_settings.c
index 383b6e7f93..cc49dd4f69 100644
--- a/src/core/transport/chttp2/frame_settings.c
+++ b/src/core/transport/chttp2/frame_settings.c
@@ -67,11 +67,10 @@ const grpc_chttp2_setting_parameters
GRPC_CHTTP2_PROTOCOL_ERROR},
};
-static gpr_uint8 *fill_header(gpr_uint8 *out, gpr_uint32 length,
- gpr_uint8 flags) {
- *out++ = (gpr_uint8)(length >> 16);
- *out++ = (gpr_uint8)(length >> 8);
- *out++ = (gpr_uint8)(length);
+static uint8_t *fill_header(uint8_t *out, uint32_t length, uint8_t flags) {
+ *out++ = (uint8_t)(length >> 16);
+ *out++ = (uint8_t)(length >> 8);
+ *out++ = (uint8_t)(length);
*out++ = GRPC_CHTTP2_FRAME_SETTINGS;
*out++ = flags;
*out++ = 0;
@@ -81,12 +80,12 @@ static gpr_uint8 *fill_header(gpr_uint8 *out, gpr_uint32 length,
return out;
}
-gpr_slice grpc_chttp2_settings_create(gpr_uint32 *old, const gpr_uint32 *new,
- gpr_uint32 force_mask, size_t count) {
+gpr_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new,
+ uint32_t force_mask, size_t count) {
size_t i;
- gpr_uint32 n = 0;
+ uint32_t n = 0;
gpr_slice output;
- gpr_uint8 *p;
+ uint8_t *p;
for (i = 0; i < count; i++) {
n += (new[i] != old[i] || (force_mask & (1u << i)) != 0);
@@ -98,12 +97,12 @@ gpr_slice grpc_chttp2_settings_create(gpr_uint32 *old, const gpr_uint32 *new,
for (i = 0; i < count; i++) {
if (new[i] != old[i] || (force_mask & (1u << i)) != 0) {
GPR_ASSERT(i);
- *p++ = (gpr_uint8)(i >> 8);
- *p++ = (gpr_uint8)(i);
- *p++ = (gpr_uint8)(new[i] >> 24);
- *p++ = (gpr_uint8)(new[i] >> 16);
- *p++ = (gpr_uint8)(new[i] >> 8);
- *p++ = (gpr_uint8)(new[i]);
+ *p++ = (uint8_t)(i >> 8);
+ *p++ = (uint8_t)(i);
+ *p++ = (uint8_t)(new[i] >> 24);
+ *p++ = (uint8_t)(new[i] >> 16);
+ *p++ = (uint8_t)(new[i] >> 8);
+ *p++ = (uint8_t)(new[i]);
old[i] = new[i];
}
}
@@ -120,11 +119,11 @@ gpr_slice grpc_chttp2_settings_ack_create(void) {
}
grpc_chttp2_parse_error grpc_chttp2_settings_parser_begin_frame(
- grpc_chttp2_settings_parser *parser, gpr_uint32 length, gpr_uint8 flags,
- gpr_uint32 *settings) {
+ grpc_chttp2_settings_parser *parser, uint32_t length, uint8_t flags,
+ uint32_t *settings) {
parser->target_settings = settings;
memcpy(parser->incoming_settings, settings,
- GRPC_CHTTP2_NUM_SETTINGS * sizeof(gpr_uint32));
+ GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t));
parser->is_ack = 0;
parser->state = GRPC_CHTTP2_SPS_ID0;
if (flags == GRPC_CHTTP2_FLAG_ACK) {
@@ -150,8 +149,8 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
grpc_chttp2_settings_parser *parser = p;
- const gpr_uint8 *cur = GPR_SLICE_START_PTR(slice);
- const gpr_uint8 *end = GPR_SLICE_END_PTR(slice);
+ const uint8_t *cur = GPR_SLICE_START_PTR(slice);
+ const uint8_t *end = GPR_SLICE_END_PTR(slice);
if (parser->is_ack) {
return GRPC_CHTTP2_PARSE_OK;
@@ -165,13 +164,13 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
if (is_last) {
transport_parsing->settings_updated = 1;
memcpy(parser->target_settings, parser->incoming_settings,
- GRPC_CHTTP2_NUM_SETTINGS * sizeof(gpr_uint32));
+ GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t));
gpr_slice_buffer_add(&transport_parsing->qbuf,
grpc_chttp2_settings_ack_create());
}
return GRPC_CHTTP2_PARSE_OK;
}
- parser->id = (gpr_uint16)(((gpr_uint16)*cur) << 8);
+ parser->id = (uint16_t)(((uint16_t)*cur) << 8);
cur++;
/* fallthrough */
case GRPC_CHTTP2_SPS_ID1:
@@ -179,7 +178,7 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
parser->state = GRPC_CHTTP2_SPS_ID1;
return GRPC_CHTTP2_PARSE_OK;
}
- parser->id = (gpr_uint16)(parser->id | (*cur));
+ parser->id = (uint16_t)(parser->id | (*cur));
cur++;
/* fallthrough */
case GRPC_CHTTP2_SPS_VAL0:
@@ -187,7 +186,7 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
parser->state = GRPC_CHTTP2_SPS_VAL0;
return GRPC_CHTTP2_PARSE_OK;
}
- parser->value = ((gpr_uint32)*cur) << 24;
+ parser->value = ((uint32_t)*cur) << 24;
cur++;
/* fallthrough */
case GRPC_CHTTP2_SPS_VAL1:
@@ -195,7 +194,7 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
parser->state = GRPC_CHTTP2_SPS_VAL1;
return GRPC_CHTTP2_PARSE_OK;
}
- parser->value |= ((gpr_uint32)*cur) << 16;
+ parser->value |= ((uint32_t)*cur) << 16;
cur++;
/* fallthrough */
case GRPC_CHTTP2_SPS_VAL2:
@@ -203,7 +202,7 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
parser->state = GRPC_CHTTP2_SPS_VAL2;
return GRPC_CHTTP2_PARSE_OK;
}
- parser->value |= ((gpr_uint32)*cur) << 8;
+ parser->value |= ((uint32_t)*cur) << 8;
cur++;
/* fallthrough */
case GRPC_CHTTP2_SPS_VAL3:
@@ -238,10 +237,11 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
if (parser->id == GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE &&
parser->incoming_settings[parser->id] != parser->value) {
transport_parsing->initial_window_update =
- (gpr_int64)parser->value -
- parser->incoming_settings[parser->id];
- gpr_log(GPR_DEBUG, "adding %d for initial_window change",
- (int)transport_parsing->initial_window_update);
+ (int64_t)parser->value - parser->incoming_settings[parser->id];
+ if (grpc_http_trace) {
+ gpr_log(GPR_DEBUG, "adding %d for initial_window change",
+ (int)transport_parsing->initial_window_update);
+ }
}
parser->incoming_settings[parser->id] = parser->value;
if (grpc_http_trace) {
diff --git a/src/core/transport/chttp2/frame_settings.h b/src/core/transport/chttp2/frame_settings.h
index e9c3c440b5..3c918e3a2a 100644
--- a/src/core/transport/chttp2/frame_settings.h
+++ b/src/core/transport/chttp2/frame_settings.h
@@ -61,11 +61,11 @@ typedef enum {
typedef struct {
grpc_chttp2_settings_parse_state state;
- gpr_uint32 *target_settings;
- gpr_uint8 is_ack;
- gpr_uint16 id;
- gpr_uint32 value;
- gpr_uint32 incoming_settings[GRPC_CHTTP2_NUM_SETTINGS];
+ uint32_t *target_settings;
+ uint8_t is_ack;
+ uint16_t id;
+ uint32_t value;
+ uint32_t incoming_settings[GRPC_CHTTP2_NUM_SETTINGS];
} grpc_chttp2_settings_parser;
typedef enum {
@@ -75,11 +75,11 @@ typedef enum {
typedef struct {
const char *name;
- gpr_uint32 default_value;
- gpr_uint32 min_value;
- gpr_uint32 max_value;
+ uint32_t default_value;
+ uint32_t min_value;
+ uint32_t max_value;
grpc_chttp2_invalid_value_behavior invalid_value_behavior;
- gpr_uint32 error_value;
+ uint32_t error_value;
} grpc_chttp2_setting_parameters;
/* HTTP/2 mandated connection setting parameters */
@@ -87,14 +87,14 @@ extern const grpc_chttp2_setting_parameters
grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS];
/* Create a settings frame by diffing old & new, and updating old to be new */
-gpr_slice grpc_chttp2_settings_create(gpr_uint32 *old, const gpr_uint32 *new,
- gpr_uint32 force_mask, size_t count);
+gpr_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new,
+ uint32_t force_mask, size_t count);
/* Create an ack settings frame */
gpr_slice grpc_chttp2_settings_ack_create(void);
grpc_chttp2_parse_error grpc_chttp2_settings_parser_begin_frame(
- grpc_chttp2_settings_parser *parser, gpr_uint32 length, gpr_uint8 flags,
- gpr_uint32 *settings);
+ grpc_chttp2_settings_parser *parser, uint32_t length, uint8_t flags,
+ uint32_t *settings);
grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
diff --git a/src/core/transport/chttp2/frame_window_update.c b/src/core/transport/chttp2/frame_window_update.c
index 74ca29baf9..62d9bac117 100644
--- a/src/core/transport/chttp2/frame_window_update.c
+++ b/src/core/transport/chttp2/frame_window_update.c
@@ -36,10 +36,10 @@
#include <grpc/support/log.h>
-gpr_slice grpc_chttp2_window_update_create(gpr_uint32 id,
- gpr_uint32 window_update) {
+gpr_slice grpc_chttp2_window_update_create(uint32_t id,
+ uint32_t window_update) {
gpr_slice slice = gpr_slice_malloc(13);
- gpr_uint8 *p = GPR_SLICE_START_PTR(slice);
+ uint8_t *p = GPR_SLICE_START_PTR(slice);
GPR_ASSERT(window_update);
@@ -48,21 +48,20 @@ gpr_slice grpc_chttp2_window_update_create(gpr_uint32 id,
*p++ = 4;
*p++ = GRPC_CHTTP2_FRAME_WINDOW_UPDATE;
*p++ = 0;
- *p++ = (gpr_uint8)(id >> 24);
- *p++ = (gpr_uint8)(id >> 16);
- *p++ = (gpr_uint8)(id >> 8);
- *p++ = (gpr_uint8)(id);
- *p++ = (gpr_uint8)(window_update >> 24);
- *p++ = (gpr_uint8)(window_update >> 16);
- *p++ = (gpr_uint8)(window_update >> 8);
- *p++ = (gpr_uint8)(window_update);
+ *p++ = (uint8_t)(id >> 24);
+ *p++ = (uint8_t)(id >> 16);
+ *p++ = (uint8_t)(id >> 8);
+ *p++ = (uint8_t)(id);
+ *p++ = (uint8_t)(window_update >> 24);
+ *p++ = (uint8_t)(window_update >> 16);
+ *p++ = (uint8_t)(window_update >> 8);
+ *p++ = (uint8_t)(window_update);
return slice;
}
grpc_chttp2_parse_error grpc_chttp2_window_update_parser_begin_frame(
- grpc_chttp2_window_update_parser *parser, gpr_uint32 length,
- gpr_uint8 flags) {
+ grpc_chttp2_window_update_parser *parser, uint32_t length, uint8_t flags) {
if (flags || length != 4) {
gpr_log(GPR_ERROR, "invalid window update: length=%d, flags=%02x", length,
flags);
@@ -77,19 +76,19 @@ grpc_chttp2_parse_error grpc_chttp2_window_update_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
- gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
- gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
- gpr_uint8 *cur = beg;
+ uint8_t *const beg = GPR_SLICE_START_PTR(slice);
+ uint8_t *const end = GPR_SLICE_END_PTR(slice);
+ uint8_t *cur = beg;
grpc_chttp2_window_update_parser *p = parser;
while (p->byte != 4 && cur != end) {
- p->amount |= ((gpr_uint32)*cur) << (8 * (3 - p->byte));
+ p->amount |= ((uint32_t)*cur) << (8 * (3 - p->byte));
cur++;
p->byte++;
}
if (p->byte == 4) {
- gpr_uint32 received_update = p->amount;
+ uint32_t received_update = p->amount;
if (received_update == 0 || (received_update & 0x80000000u)) {
gpr_log(GPR_ERROR, "invalid window update bytes: %d", p->amount);
return GRPC_CHTTP2_CONNECTION_ERROR;
diff --git a/src/core/transport/chttp2/frame_window_update.h b/src/core/transport/chttp2/frame_window_update.h
index fc074092ff..89d835c079 100644
--- a/src/core/transport/chttp2/frame_window_update.h
+++ b/src/core/transport/chttp2/frame_window_update.h
@@ -39,17 +39,15 @@
#include "src/core/transport/chttp2/frame.h"
typedef struct {
- gpr_uint8 byte;
- gpr_uint8 is_connection_update;
- gpr_uint32 amount;
+ uint8_t byte;
+ uint8_t is_connection_update;
+ uint32_t amount;
} grpc_chttp2_window_update_parser;
-gpr_slice grpc_chttp2_window_update_create(gpr_uint32 id,
- gpr_uint32 window_delta);
+gpr_slice grpc_chttp2_window_update_create(uint32_t id, uint32_t window_delta);
grpc_chttp2_parse_error grpc_chttp2_window_update_parser_begin_frame(
- grpc_chttp2_window_update_parser *parser, gpr_uint32 length,
- gpr_uint8 flags);
+ grpc_chttp2_window_update_parser *parser, uint32_t length, uint8_t flags);
grpc_chttp2_parse_error grpc_chttp2_window_update_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport_parsing *transport_parsing,
diff --git a/src/core/transport/chttp2/hpack_encoder.c b/src/core/transport/chttp2/hpack_encoder.c
index 303b8f332a..89a80d896c 100644
--- a/src/core/transport/chttp2/hpack_encoder.c
+++ b/src/core/transport/chttp2/hpack_encoder.c
@@ -70,39 +70,38 @@ typedef struct {
/* index (in output) of the header for the current frame */
size_t header_idx;
/* have we seen a regular (non-colon-prefixed) header yet? */
- gpr_uint8 seen_regular_header;
+ uint8_t seen_regular_header;
/* output stream id */
- gpr_uint32 stream_id;
+ uint32_t stream_id;
gpr_slice_buffer *output;
} framer_state;
/* fills p (which is expected to be 9 bytes long) with a data frame header */
-static void fill_header(gpr_uint8 *p, gpr_uint8 type, gpr_uint32 id, size_t len,
- gpr_uint8 flags) {
+static void fill_header(uint8_t *p, uint8_t type, uint32_t id, size_t len,
+ uint8_t flags) {
GPR_ASSERT(len < 16777316);
- *p++ = (gpr_uint8)(len >> 16);
- *p++ = (gpr_uint8)(len >> 8);
- *p++ = (gpr_uint8)(len);
+ *p++ = (uint8_t)(len >> 16);
+ *p++ = (uint8_t)(len >> 8);
+ *p++ = (uint8_t)(len);
*p++ = type;
*p++ = flags;
- *p++ = (gpr_uint8)(id >> 24);
- *p++ = (gpr_uint8)(id >> 16);
- *p++ = (gpr_uint8)(id >> 8);
- *p++ = (gpr_uint8)(id);
+ *p++ = (uint8_t)(id >> 24);
+ *p++ = (uint8_t)(id >> 16);
+ *p++ = (uint8_t)(id >> 8);
+ *p++ = (uint8_t)(id);
}
/* finish a frame - fill in the previously reserved header */
static void finish_frame(framer_state *st, int is_header_boundary,
int is_last_in_stream) {
- gpr_uint8 type = 0xff;
+ uint8_t type = 0xff;
type = st->is_first_frame ? GRPC_CHTTP2_FRAME_HEADER
: GRPC_CHTTP2_FRAME_CONTINUATION;
fill_header(
GPR_SLICE_START_PTR(st->output->slices[st->header_idx]), type,
st->stream_id, st->output->length - st->output_length_at_start_of_frame,
- (gpr_uint8)(
- (is_last_in_stream ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0) |
- (is_header_boundary ? GRPC_CHTTP2_DATA_FLAG_END_HEADERS : 0)));
+ (uint8_t)((is_last_in_stream ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0) |
+ (is_header_boundary ? GRPC_CHTTP2_DATA_FLAG_END_HEADERS : 0)));
st->is_first_frame = 0;
}
@@ -127,7 +126,7 @@ static void ensure_space(framer_state *st, size_t need_bytes) {
}
/* increment a filter count, halve all counts if one element reaches max */
-static void inc_filter(gpr_uint8 idx, gpr_uint32 *sum, gpr_uint8 *elems) {
+static void inc_filter(uint8_t idx, uint32_t *sum, uint8_t *elems) {
elems[idx]++;
if (elems[idx] < 255) {
(*sum)++;
@@ -157,7 +156,7 @@ static void add_header_data(framer_state *st, gpr_slice slice) {
}
}
-static gpr_uint8 *add_tiny_header_data(framer_state *st, size_t len) {
+static uint8_t *add_tiny_header_data(framer_state *st, size_t len) {
ensure_space(st, len);
return gpr_slice_buffer_tiny_add(st->output, len);
}
@@ -168,17 +167,17 @@ static void evict_entry(grpc_chttp2_hpack_compressor *c) {
GPR_ASSERT(c->table_size >=
c->table_elem_size[c->tail_remote_index % c->cap_table_elems]);
GPR_ASSERT(c->table_elems > 0);
- c->table_size = (gpr_uint16)(
- c->table_size -
- c->table_elem_size[c->tail_remote_index % c->cap_table_elems]);
+ c->table_size =
+ (uint16_t)(c->table_size -
+ c->table_elem_size[c->tail_remote_index % c->cap_table_elems]);
c->table_elems--;
}
/* add an element to the decoder table */
static void add_elem(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem) {
- gpr_uint32 key_hash = elem->key->hash;
- gpr_uint32 elem_hash = GRPC_MDSTR_KV_HASH(key_hash, elem->value->hash);
- gpr_uint32 new_index = c->tail_remote_index + c->table_elems + 1;
+ uint32_t key_hash = elem->key->hash;
+ uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, elem->value->hash);
+ uint32_t new_index = c->tail_remote_index + c->table_elems + 1;
size_t elem_size = 32 + GPR_SLICE_LENGTH(elem->key->slice) +
GPR_SLICE_LENGTH(elem->value->slice);
@@ -198,8 +197,8 @@ static void add_elem(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem) {
evict_entry(c);
}
GPR_ASSERT(c->table_elems < c->max_table_size);
- c->table_elem_size[new_index % c->cap_table_elems] = (gpr_uint16)elem_size;
- c->table_size = (gpr_uint16)(c->table_size + elem_size);
+ c->table_elem_size[new_index % c->cap_table_elems] = (uint16_t)elem_size;
+ c->table_size = (uint16_t)(c->table_size + elem_size);
c->table_elems++;
/* Store this element into {entries,indices}_elem */
@@ -254,14 +253,14 @@ static void add_elem(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem) {
}
}
-static void emit_indexed(grpc_chttp2_hpack_compressor *c, gpr_uint32 elem_index,
+static void emit_indexed(grpc_chttp2_hpack_compressor *c, uint32_t elem_index,
framer_state *st) {
- gpr_uint32 len = GRPC_CHTTP2_VARINT_LENGTH(elem_index, 1);
+ uint32_t len = GRPC_CHTTP2_VARINT_LENGTH(elem_index, 1);
GRPC_CHTTP2_WRITE_VARINT(elem_index, 1, 0x80, add_tiny_header_data(st, len),
len);
}
-static gpr_slice get_wire_value(grpc_mdelem *elem, gpr_uint8 *huffman_prefix) {
+static gpr_slice get_wire_value(grpc_mdelem *elem, uint8_t *huffman_prefix) {
if (grpc_is_binary_header((const char *)GPR_SLICE_START_PTR(elem->key->slice),
GPR_SLICE_LENGTH(elem->key->slice))) {
*huffman_prefix = 0x80;
@@ -273,49 +272,49 @@ static gpr_slice get_wire_value(grpc_mdelem *elem, gpr_uint8 *huffman_prefix) {
}
static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c,
- gpr_uint32 key_index, grpc_mdelem *elem,
+ uint32_t key_index, grpc_mdelem *elem,
framer_state *st) {
- gpr_uint32 len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2);
- gpr_uint8 huffman_prefix;
+ uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2);
+ uint8_t huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
size_t len_val = GPR_SLICE_LENGTH(value_slice);
- gpr_uint32 len_val_len;
- GPR_ASSERT(len_val <= GPR_UINT32_MAX);
- len_val_len = GRPC_CHTTP2_VARINT_LENGTH((gpr_uint32)len_val, 1);
+ uint32_t len_val_len;
+ GPR_ASSERT(len_val <= UINT32_MAX);
+ len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1);
GRPC_CHTTP2_WRITE_VARINT(key_index, 2, 0x40,
add_tiny_header_data(st, len_pfx), len_pfx);
- GRPC_CHTTP2_WRITE_VARINT((gpr_uint32)len_val, 1, 0x00,
+ GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, 0x00,
add_tiny_header_data(st, len_val_len), len_val_len);
add_header_data(st, gpr_slice_ref(value_slice));
}
static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c,
- gpr_uint32 key_index, grpc_mdelem *elem,
+ uint32_t key_index, grpc_mdelem *elem,
framer_state *st) {
- gpr_uint32 len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4);
- gpr_uint8 huffman_prefix;
+ uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4);
+ uint8_t huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
size_t len_val = GPR_SLICE_LENGTH(value_slice);
- gpr_uint32 len_val_len;
- GPR_ASSERT(len_val <= GPR_UINT32_MAX);
- len_val_len = GRPC_CHTTP2_VARINT_LENGTH((gpr_uint32)len_val, 1);
+ uint32_t len_val_len;
+ GPR_ASSERT(len_val <= UINT32_MAX);
+ len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1);
GRPC_CHTTP2_WRITE_VARINT(key_index, 4, 0x00,
add_tiny_header_data(st, len_pfx), len_pfx);
- GRPC_CHTTP2_WRITE_VARINT((gpr_uint32)len_val, 1, 0x00,
+ GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, 0x00,
add_tiny_header_data(st, len_val_len), len_val_len);
add_header_data(st, gpr_slice_ref(value_slice));
}
static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c,
grpc_mdelem *elem, framer_state *st) {
- gpr_uint32 len_key = (gpr_uint32)GPR_SLICE_LENGTH(elem->key->slice);
- gpr_uint8 huffman_prefix;
+ uint32_t len_key = (uint32_t)GPR_SLICE_LENGTH(elem->key->slice);
+ uint8_t huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
- gpr_uint32 len_val = (gpr_uint32)GPR_SLICE_LENGTH(value_slice);
- gpr_uint32 len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
- gpr_uint32 len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
- GPR_ASSERT(len_key <= GPR_UINT32_MAX);
- GPR_ASSERT(GPR_SLICE_LENGTH(value_slice) <= GPR_UINT32_MAX);
+ uint32_t len_val = (uint32_t)GPR_SLICE_LENGTH(value_slice);
+ uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
+ uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
+ GPR_ASSERT(len_key <= UINT32_MAX);
+ GPR_ASSERT(GPR_SLICE_LENGTH(value_slice) <= UINT32_MAX);
*add_tiny_header_data(st, 1) = 0x40;
GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00,
add_tiny_header_data(st, len_key_len), len_key_len);
@@ -327,14 +326,14 @@ static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c,
static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor *c,
grpc_mdelem *elem, framer_state *st) {
- gpr_uint32 len_key = (gpr_uint32)GPR_SLICE_LENGTH(elem->key->slice);
- gpr_uint8 huffman_prefix;
+ uint32_t len_key = (uint32_t)GPR_SLICE_LENGTH(elem->key->slice);
+ uint8_t huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
- gpr_uint32 len_val = (gpr_uint32)GPR_SLICE_LENGTH(value_slice);
- gpr_uint32 len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
- gpr_uint32 len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
- GPR_ASSERT(len_key <= GPR_UINT32_MAX);
- GPR_ASSERT(GPR_SLICE_LENGTH(value_slice) <= GPR_UINT32_MAX);
+ uint32_t len_val = (uint32_t)GPR_SLICE_LENGTH(value_slice);
+ uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
+ uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
+ GPR_ASSERT(len_key <= UINT32_MAX);
+ GPR_ASSERT(GPR_SLICE_LENGTH(value_slice) <= UINT32_MAX);
*add_tiny_header_data(st, 1) = 0x00;
GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00,
add_tiny_header_data(st, len_key_len), len_key_len);
@@ -346,14 +345,13 @@ static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor *c,
static void emit_advertise_table_size_change(grpc_chttp2_hpack_compressor *c,
framer_state *st) {
- gpr_uint32 len = GRPC_CHTTP2_VARINT_LENGTH(c->max_table_size, 3);
+ uint32_t len = GRPC_CHTTP2_VARINT_LENGTH(c->max_table_size, 3);
GRPC_CHTTP2_WRITE_VARINT(c->max_table_size, 3, 0x20,
add_tiny_header_data(st, len), len);
c->advertise_table_size_change = 0;
}
-static gpr_uint32 dynidx(grpc_chttp2_hpack_compressor *c,
- gpr_uint32 elem_index) {
+static uint32_t dynidx(grpc_chttp2_hpack_compressor *c, uint32_t elem_index) {
return 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY + c->tail_remote_index +
c->table_elems - elem_index;
}
@@ -361,10 +359,10 @@ static gpr_uint32 dynidx(grpc_chttp2_hpack_compressor *c,
/* encode an mdelem */
static void hpack_enc(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem,
framer_state *st) {
- gpr_uint32 key_hash = elem->key->hash;
- gpr_uint32 elem_hash = GRPC_MDSTR_KV_HASH(key_hash, elem->value->hash);
+ uint32_t key_hash = elem->key->hash;
+ uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, elem->value->hash);
size_t decoder_space_usage;
- gpr_uint32 indices_key;
+ uint32_t indices_key;
int should_add_elem;
GPR_ASSERT(GPR_SLICE_LENGTH(elem->key->slice) > 0);
@@ -463,9 +461,7 @@ static void deadline_enc(grpc_chttp2_hpack_compressor *c, gpr_timespec deadline,
GRPC_MDELEM_UNREF(mdelem);
}
-static gpr_uint32 elems_for_bytes(gpr_uint32 bytes) {
- return (bytes + 31) / 32;
-}
+static uint32_t elems_for_bytes(uint32_t bytes) { return (bytes + 31) / 32; }
void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c) {
memset(c, 0, sizeof(*c));
@@ -489,21 +485,21 @@ void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor *c) {
}
void grpc_chttp2_hpack_compressor_set_max_usable_size(
- grpc_chttp2_hpack_compressor *c, gpr_uint32 max_table_size) {
+ grpc_chttp2_hpack_compressor *c, uint32_t max_table_size) {
c->max_usable_size = max_table_size;
grpc_chttp2_hpack_compressor_set_max_table_size(
c, GPR_MIN(c->max_table_size, max_table_size));
}
-static void rebuild_elems(grpc_chttp2_hpack_compressor *c, gpr_uint32 new_cap) {
- gpr_uint16 *table_elem_size = gpr_malloc(sizeof(*table_elem_size) * new_cap);
- gpr_uint32 i;
+static void rebuild_elems(grpc_chttp2_hpack_compressor *c, uint32_t new_cap) {
+ uint16_t *table_elem_size = gpr_malloc(sizeof(*table_elem_size) * new_cap);
+ uint32_t i;
memset(table_elem_size, 0, sizeof(*table_elem_size) * new_cap);
GPR_ASSERT(c->table_elems <= new_cap);
for (i = 0; i < c->table_elems; i++) {
- gpr_uint32 ofs = c->tail_remote_index + i + 1;
+ uint32_t ofs = c->tail_remote_index + i + 1;
table_elem_size[ofs % new_cap] =
c->table_elem_size[ofs % c->cap_table_elems];
}
@@ -514,7 +510,7 @@ static void rebuild_elems(grpc_chttp2_hpack_compressor *c, gpr_uint32 new_cap) {
}
void grpc_chttp2_hpack_compressor_set_max_table_size(
- grpc_chttp2_hpack_compressor *c, gpr_uint32 max_table_size) {
+ grpc_chttp2_hpack_compressor *c, uint32_t max_table_size) {
max_table_size = GPR_MIN(max_table_size, c->max_usable_size);
if (max_table_size == c->max_table_size) {
return;
@@ -527,7 +523,7 @@ void grpc_chttp2_hpack_compressor_set_max_table_size(
if (c->max_table_elems > c->cap_table_elems) {
rebuild_elems(c, GPR_MAX(c->max_table_elems, 2 * c->cap_table_elems));
} else if (c->max_table_elems < c->cap_table_elems / 3) {
- gpr_uint32 new_cap = GPR_MAX(c->max_table_elems, 16);
+ uint32_t new_cap = GPR_MAX(c->max_table_elems, 16);
if (new_cap != c->cap_table_elems) {
rebuild_elems(c, new_cap);
}
@@ -537,7 +533,7 @@ void grpc_chttp2_hpack_compressor_set_max_table_size(
}
void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor *c,
- gpr_uint32 stream_id,
+ uint32_t stream_id,
grpc_metadata_batch *metadata, int is_eof,
gpr_slice_buffer *outbuf) {
framer_state st;
diff --git a/src/core/transport/chttp2/hpack_encoder.h b/src/core/transport/chttp2/hpack_encoder.h
index a3600436e9..19b5cb72ae 100644
--- a/src/core/transport/chttp2/hpack_encoder.h
+++ b/src/core/transport/chttp2/hpack_encoder.h
@@ -49,46 +49,46 @@
#define GRPC_CHTTP2_HPACKC_MAX_TABLE_SIZE (1024 * 1024)
typedef struct {
- gpr_uint32 filter_elems_sum;
- gpr_uint32 max_table_size;
- gpr_uint32 max_table_elems;
- gpr_uint32 cap_table_elems;
+ uint32_t filter_elems_sum;
+ uint32_t max_table_size;
+ uint32_t max_table_elems;
+ uint32_t cap_table_elems;
/** if non-zero, advertise to the decoder that we'll start using a table
of this size */
- gpr_uint8 advertise_table_size_change;
+ uint8_t advertise_table_size_change;
/** maximum number of bytes we'll use for the decode table (to guard against
peers ooming us by setting decode table size high) */
- gpr_uint32 max_usable_size;
+ uint32_t max_usable_size;
/* one before the lowest usable table index */
- gpr_uint32 tail_remote_index;
- gpr_uint32 table_size;
- gpr_uint32 table_elems;
+ uint32_t tail_remote_index;
+ uint32_t table_size;
+ uint32_t table_elems;
/* filter tables for elems: this tables provides an approximate
popularity count for particular hashes, and are used to determine whether
a new literal should be added to the compression table or not.
They track a single integer that counts how often a particular value has
been seen. When that count reaches max (255), all values are halved. */
- gpr_uint8 filter_elems[GRPC_CHTTP2_HPACKC_NUM_FILTERS];
+ uint8_t filter_elems[GRPC_CHTTP2_HPACKC_NUM_FILTERS];
/* entry tables for keys & elems: these tables track values that have been
seen and *may* be in the decompressor table */
grpc_mdstr *entries_keys[GRPC_CHTTP2_HPACKC_NUM_VALUES];
grpc_mdelem *entries_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES];
- gpr_uint32 indices_keys[GRPC_CHTTP2_HPACKC_NUM_VALUES];
- gpr_uint32 indices_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES];
+ uint32_t indices_keys[GRPC_CHTTP2_HPACKC_NUM_VALUES];
+ uint32_t indices_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES];
- gpr_uint16 *table_elem_size;
+ uint16_t *table_elem_size;
} grpc_chttp2_hpack_compressor;
void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c);
void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor *c);
void grpc_chttp2_hpack_compressor_set_max_table_size(
- grpc_chttp2_hpack_compressor *c, gpr_uint32 max_table_size);
+ grpc_chttp2_hpack_compressor *c, uint32_t max_table_size);
void grpc_chttp2_hpack_compressor_set_max_usable_size(
- grpc_chttp2_hpack_compressor *c, gpr_uint32 max_table_size);
+ grpc_chttp2_hpack_compressor *c, uint32_t max_table_size);
-void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor *c, gpr_uint32 id,
+void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor *c, uint32_t id,
grpc_metadata_batch *metadata, int is_eof,
gpr_slice_buffer *outbuf);
diff --git a/src/core/transport/chttp2/hpack_parser.c b/src/core/transport/chttp2/hpack_parser.c
index 48790c2ef2..a63c7db1f6 100644
--- a/src/core/transport/chttp2/hpack_parser.c
+++ b/src/core/transport/chttp2/hpack_parser.c
@@ -75,63 +75,63 @@ typedef enum {
a set of indirect jumps, and so not waste stack space. */
/* forward declarations for parsing states */
-static int parse_begin(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_error(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_illegal_op(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-
-static int parse_string_prefix(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
-static int parse_key_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
+static int parse_begin(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_error(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_illegal_op(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+
+static int parse_string_prefix(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_key_string(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
static int parse_value_string_with_indexed_key(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur,
- const gpr_uint8 *end);
+ const uint8_t *cur,
+ const uint8_t *end);
static int parse_value_string_with_literal_key(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur,
- const gpr_uint8 *end);
-
-static int parse_value0(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_value1(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_value2(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_value3(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_value4(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_value5up(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-
-static int parse_indexed_field(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur,
+ const uint8_t *end);
+
+static int parse_value0(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_value1(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_value2(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_value3(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_value4(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_value5up(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+
+static int parse_indexed_field(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
static int parse_indexed_field_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
-static int parse_lithdr_incidx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur, const uint8_t *end);
+static int parse_lithdr_incidx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
static int parse_lithdr_incidx_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur, const uint8_t *end);
static int parse_lithdr_incidx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
-static int parse_lithdr_notidx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur, const uint8_t *end);
+static int parse_lithdr_notidx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
static int parse_lithdr_notidx_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur, const uint8_t *end);
static int parse_lithdr_notidx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
-static int parse_lithdr_nvridx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur, const uint8_t *end);
+static int parse_lithdr_nvridx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
static int parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur, const uint8_t *end);
static int parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
-static int parse_max_tbl_size(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end);
-static int parse_max_tbl_size_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end);
+ const uint8_t *cur, const uint8_t *end);
+static int parse_max_tbl_size(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
+static int parse_max_tbl_size_x(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end);
/* we translate the first byte of a hpack field into one of these decoding
cases, then use a lookup table to jump directly to the appropriate parser.
@@ -167,7 +167,7 @@ static const grpc_chttp2_hpack_parser_state first_byte_action[] = {
/* indexes the first byte to a parse state function - generated by
gen_hpack_tables.c */
-static const gpr_uint8 first_byte_lut[256] = {
+static const uint8_t first_byte_lut[256] = {
LITHDR_NOTIDX_V, LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX,
LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX,
LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX, LITHDR_NOTIDX,
@@ -239,7 +239,7 @@ static const gpr_uint8 first_byte_lut[256] = {
considered returns the next state.
generated by gen_hpack_tables.c */
-static const gpr_uint8 next_tbl[256] = {
+static const uint8_t next_tbl[256] = {
0, 1, 2, 3, 4, 1, 2, 5, 6, 1, 7, 8, 1, 3, 3, 9, 10, 11, 1, 1,
1, 12, 1, 2, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
14, 1, 15, 16, 1, 17, 1, 15, 2, 7, 3, 18, 19, 1, 1, 1, 1, 20, 1, 1,
@@ -257,7 +257,7 @@ static const gpr_uint8 next_tbl[256] = {
/* next state, based upon current state and the current nibble: see above.
generated by gen_hpack_tables.c */
-static const gpr_int16 next_sub_tbl[48 * 16] = {
+static const int16_t next_sub_tbl[48 * 16] = {
1, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
218, 2, 6, 10, 13, 14, 15, 16, 17, 2, 6, 10, 13, 14, 15,
16, 17, 3, 7, 11, 24, 3, 7, 11, 24, 3, 7, 11, 24, 3,
@@ -316,7 +316,7 @@ static const gpr_int16 next_sub_tbl[48 * 16] = {
emitted, or -1 for no byte, or 256 for end of stream
generated by gen_hpack_tables.c */
-static const gpr_uint16 emit_tbl[256] = {
+static const uint16_t emit_tbl[256] = {
0, 1, 2, 3, 4, 5, 6, 7, 0, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 0, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
@@ -338,7 +338,7 @@ static const gpr_uint16 emit_tbl[256] = {
};
/* generated by gen_hpack_tables.c */
-static const gpr_int16 emit_sub_tbl[249 * 16] = {
+static const int16_t emit_sub_tbl[249 * 16] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 48, 48, 48, 48, 48, 48, 48, 48, 49, 49, 49, 49, 49, 49,
49, 49, 48, 48, 48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 97,
@@ -607,7 +607,7 @@ static const gpr_int16 emit_sub_tbl[249 * 16] = {
13, 22, 22, 22, 22, 256, 256, 256, 256,
};
-static const gpr_uint8 inverse_base64[256] = {
+static const uint8_t inverse_base64[256] = {
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255,
@@ -642,22 +642,22 @@ static int on_hdr(grpc_chttp2_hpack_parser *p, grpc_mdelem *md,
static grpc_mdstr *take_string(grpc_chttp2_hpack_parser *p,
grpc_chttp2_hpack_parser_string *str) {
- grpc_mdstr *s = grpc_mdstr_from_buffer((gpr_uint8 *)str->str, str->length);
+ grpc_mdstr *s = grpc_mdstr_from_buffer((uint8_t *)str->str, str->length);
str->length = 0;
return s;
}
/* jump to the next state */
-static int parse_next(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_next(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
p->state = *p->next_state++;
return p->state(p, cur, end);
}
/* begin parsing a header: all functionality is encoded into lookup tables
above */
-static int parse_begin(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_begin(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_begin;
return 1;
@@ -667,8 +667,8 @@ static int parse_begin(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
}
/* stream dependency and prioritization data: we just skip it */
-static int parse_stream_weight(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int parse_stream_weight(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_stream_weight;
return 1;
@@ -677,8 +677,8 @@ static int parse_stream_weight(grpc_chttp2_hpack_parser *p,
return p->after_prioritization(p, cur + 1, end);
}
-static int parse_stream_dep3(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_stream_dep3(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_stream_dep3;
return 1;
@@ -687,8 +687,8 @@ static int parse_stream_dep3(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
return parse_stream_weight(p, cur + 1, end);
}
-static int parse_stream_dep2(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_stream_dep2(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_stream_dep2;
return 1;
@@ -697,8 +697,8 @@ static int parse_stream_dep2(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
return parse_stream_dep3(p, cur + 1, end);
}
-static int parse_stream_dep1(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_stream_dep1(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_stream_dep1;
return 1;
@@ -707,8 +707,8 @@ static int parse_stream_dep1(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
return parse_stream_dep2(p, cur + 1, end);
}
-static int parse_stream_dep0(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_stream_dep0(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_stream_dep0;
return 1;
@@ -719,8 +719,8 @@ static int parse_stream_dep0(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* emit an indexed field; for now just logs it to console; jumps to
begin the next field on completion */
-static int finish_indexed_field(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int finish_indexed_field(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
if (md == NULL) {
gpr_log(GPR_ERROR, "Invalid HPACK index received: %d", p->index);
@@ -731,8 +731,8 @@ static int finish_indexed_field(grpc_chttp2_hpack_parser *p,
}
/* parse an indexed field with index < 127 */
-static int parse_indexed_field(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int parse_indexed_field(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
p->dynamic_table_update_allowed = 0;
p->index = (*cur) & 0x7f;
return finish_indexed_field(p, cur + 1, end);
@@ -740,7 +740,7 @@ static int parse_indexed_field(grpc_chttp2_hpack_parser *p,
/* parse an indexed field with index >= 127 */
static int parse_indexed_field_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
finish_indexed_field};
p->dynamic_table_update_allowed = 0;
@@ -752,8 +752,8 @@ static int parse_indexed_field_x(grpc_chttp2_hpack_parser *p,
/* finish a literal header with incremental indexing: just log, and jump to '
begin */
-static int finish_lithdr_incidx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int finish_lithdr_incidx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(md != NULL); /* handled in string parsing */
return on_hdr(p, grpc_mdelem_from_metadata_strings(GRPC_MDSTR_REF(md->key),
@@ -764,7 +764,7 @@ static int finish_lithdr_incidx(grpc_chttp2_hpack_parser *p,
/* finish a literal header with incremental indexing with no index */
static int finish_lithdr_incidx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
return on_hdr(p, grpc_mdelem_from_metadata_strings(take_string(p, &p->key),
take_string(p, &p->value)),
1) &&
@@ -772,8 +772,8 @@ static int finish_lithdr_incidx_v(grpc_chttp2_hpack_parser *p,
}
/* parse a literal header with incremental indexing; index < 63 */
-static int parse_lithdr_incidx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int parse_lithdr_incidx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_value_string_with_indexed_key, finish_lithdr_incidx};
p->dynamic_table_update_allowed = 0;
@@ -784,7 +784,7 @@ static int parse_lithdr_incidx(grpc_chttp2_hpack_parser *p,
/* parse a literal header with incremental indexing; index >= 63 */
static int parse_lithdr_incidx_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_string_prefix, parse_value_string_with_indexed_key,
finish_lithdr_incidx};
@@ -797,7 +797,7 @@ static int parse_lithdr_incidx_x(grpc_chttp2_hpack_parser *p,
/* parse a literal header with incremental indexing; index = 0 */
static int parse_lithdr_incidx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_key_string, parse_string_prefix,
parse_value_string_with_literal_key, finish_lithdr_incidx_v};
@@ -807,8 +807,8 @@ static int parse_lithdr_incidx_v(grpc_chttp2_hpack_parser *p,
}
/* finish a literal header without incremental indexing */
-static int finish_lithdr_notidx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int finish_lithdr_notidx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(md != NULL); /* handled in string parsing */
return on_hdr(p, grpc_mdelem_from_metadata_strings(GRPC_MDSTR_REF(md->key),
@@ -819,7 +819,7 @@ static int finish_lithdr_notidx(grpc_chttp2_hpack_parser *p,
/* finish a literal header without incremental indexing with index = 0 */
static int finish_lithdr_notidx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
return on_hdr(p, grpc_mdelem_from_metadata_strings(take_string(p, &p->key),
take_string(p, &p->value)),
0) &&
@@ -827,8 +827,8 @@ static int finish_lithdr_notidx_v(grpc_chttp2_hpack_parser *p,
}
/* parse a literal header without incremental indexing; index < 15 */
-static int parse_lithdr_notidx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int parse_lithdr_notidx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_value_string_with_indexed_key, finish_lithdr_notidx};
p->dynamic_table_update_allowed = 0;
@@ -839,7 +839,7 @@ static int parse_lithdr_notidx(grpc_chttp2_hpack_parser *p,
/* parse a literal header without incremental indexing; index >= 15 */
static int parse_lithdr_notidx_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_string_prefix, parse_value_string_with_indexed_key,
finish_lithdr_notidx};
@@ -852,7 +852,7 @@ static int parse_lithdr_notidx_x(grpc_chttp2_hpack_parser *p,
/* parse a literal header without incremental indexing; index == 0 */
static int parse_lithdr_notidx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_key_string, parse_string_prefix,
parse_value_string_with_literal_key, finish_lithdr_notidx_v};
@@ -862,8 +862,8 @@ static int parse_lithdr_notidx_v(grpc_chttp2_hpack_parser *p,
}
/* finish a literal header that is never indexed */
-static int finish_lithdr_nvridx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int finish_lithdr_nvridx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(md != NULL); /* handled in string parsing */
return on_hdr(p, grpc_mdelem_from_metadata_strings(GRPC_MDSTR_REF(md->key),
@@ -874,7 +874,7 @@ static int finish_lithdr_nvridx(grpc_chttp2_hpack_parser *p,
/* finish a literal header that is never indexed with an extra value */
static int finish_lithdr_nvridx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
return on_hdr(p, grpc_mdelem_from_metadata_strings(take_string(p, &p->key),
take_string(p, &p->value)),
0) &&
@@ -882,8 +882,8 @@ static int finish_lithdr_nvridx_v(grpc_chttp2_hpack_parser *p,
}
/* parse a literal header that is never indexed; index < 15 */
-static int parse_lithdr_nvridx(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int parse_lithdr_nvridx(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_value_string_with_indexed_key, finish_lithdr_nvridx};
p->dynamic_table_update_allowed = 0;
@@ -894,7 +894,7 @@ static int parse_lithdr_nvridx(grpc_chttp2_hpack_parser *p,
/* parse a literal header that is never indexed; index >= 15 */
static int parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_string_prefix, parse_value_string_with_indexed_key,
finish_lithdr_nvridx};
@@ -907,7 +907,7 @@ static int parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser *p,
/* parse a literal header that is never indexed; index == 0 */
static int parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+ const uint8_t *cur, const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_key_string, parse_string_prefix,
parse_value_string_with_literal_key, finish_lithdr_nvridx_v};
@@ -917,16 +917,16 @@ static int parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser *p,
}
/* finish parsing a max table size change */
-static int finish_max_tbl_size(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int finish_max_tbl_size(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", p->index);
return grpc_chttp2_hptbl_set_current_table_size(&p->table, p->index) &&
parse_begin(p, cur, end);
}
/* parse a max table size change, max size < 15 */
-static int parse_max_tbl_size(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_max_tbl_size(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (p->dynamic_table_update_allowed == 0) {
return 0;
}
@@ -936,8 +936,8 @@ static int parse_max_tbl_size(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
}
/* parse a max table size change, max size >= 15 */
-static int parse_max_tbl_size_x(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int parse_max_tbl_size_x(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
finish_max_tbl_size};
if (p->dynamic_table_update_allowed == 0) {
@@ -951,14 +951,14 @@ static int parse_max_tbl_size_x(grpc_chttp2_hpack_parser *p,
}
/* a parse error: jam the parse state into parse_error, and return error */
-static int parse_error(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_error(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
p->state = parse_error;
return 0;
}
-static int parse_illegal_op(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_illegal_op(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
GPR_ASSERT(cur != end);
gpr_log(GPR_DEBUG, "Illegal hpack op code %d", *cur);
return parse_error(p, cur, end);
@@ -966,8 +966,8 @@ static int parse_illegal_op(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* parse the 1st byte of a varint into p->parsing.value
no overflow is possible */
-static int parse_value0(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_value0(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_value0;
return 1;
@@ -984,14 +984,14 @@ static int parse_value0(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* parse the 2nd byte of a varint into p->parsing.value
no overflow is possible */
-static int parse_value1(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_value1(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_value1;
return 1;
}
- *p->parsing.value += (((gpr_uint32)*cur) & 0x7f) << 7;
+ *p->parsing.value += (((uint32_t)*cur) & 0x7f) << 7;
if ((*cur) & 0x80) {
return parse_value2(p, cur + 1, end);
@@ -1002,14 +1002,14 @@ static int parse_value1(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* parse the 3rd byte of a varint into p->parsing.value
no overflow is possible */
-static int parse_value2(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_value2(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_value2;
return 1;
}
- *p->parsing.value += (((gpr_uint32)*cur) & 0x7f) << 14;
+ *p->parsing.value += (((uint32_t)*cur) & 0x7f) << 14;
if ((*cur) & 0x80) {
return parse_value3(p, cur + 1, end);
@@ -1020,14 +1020,14 @@ static int parse_value2(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* parse the 4th byte of a varint into p->parsing.value
no overflow is possible */
-static int parse_value3(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_value3(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_value3;
return 1;
}
- *p->parsing.value += (((gpr_uint32)*cur) & 0x7f) << 21;
+ *p->parsing.value += (((uint32_t)*cur) & 0x7f) << 21;
if ((*cur) & 0x80) {
return parse_value4(p, cur + 1, end);
@@ -1038,11 +1038,11 @@ static int parse_value3(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* parse the 5th byte of a varint into p->parsing.value
depending on the byte, we may overflow, and care must be taken */
-static int parse_value4(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
- gpr_uint8 c;
- gpr_uint32 cur_value;
- gpr_uint32 add_value;
+static int parse_value4(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
+ uint8_t c;
+ uint32_t cur_value;
+ uint32_t add_value;
if (cur == end) {
p->state = parse_value4;
@@ -1055,7 +1055,7 @@ static int parse_value4(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
}
cur_value = *p->parsing.value;
- add_value = ((gpr_uint32)c) << 28;
+ add_value = ((uint32_t)c) << 28;
if (add_value > 0xffffffffu - cur_value) {
goto error;
}
@@ -1079,8 +1079,8 @@ error:
/* parse any trailing bytes in a varint: it's possible to append an arbitrary
number of 0x80's and not affect the value - a zero will terminate - and
anything else will overflow */
-static int parse_value5up(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_value5up(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
while (cur != end && *cur == 0x80) {
++cur;
}
@@ -1102,8 +1102,8 @@ static int parse_value5up(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
}
/* parse a string prefix */
-static int parse_string_prefix(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur, const gpr_uint8 *end) {
+static int parse_string_prefix(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (cur == end) {
p->state = parse_string_prefix;
return 1;
@@ -1121,22 +1121,22 @@ static int parse_string_prefix(grpc_chttp2_hpack_parser *p,
/* append some bytes to a string */
static void append_bytes(grpc_chttp2_hpack_parser_string *str,
- const gpr_uint8 *data, size_t length) {
+ const uint8_t *data, size_t length) {
if (length + str->length > str->capacity) {
- GPR_ASSERT(str->length + length <= GPR_UINT32_MAX);
- str->capacity = (gpr_uint32)(str->length + length);
+ GPR_ASSERT(str->length + length <= UINT32_MAX);
+ str->capacity = (uint32_t)(str->length + length);
str->str = gpr_realloc(str->str, str->capacity);
}
memcpy(str->str + str->length, data, length);
- GPR_ASSERT(length <= GPR_UINT32_MAX - str->length);
- str->length += (gpr_uint32)length;
+ GPR_ASSERT(length <= UINT32_MAX - str->length);
+ str->length += (uint32_t)length;
}
-static int append_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int append_string(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
grpc_chttp2_hpack_parser_string *str = p->parsing.str;
- gpr_uint32 bits;
- gpr_uint8 decoded[3];
+ uint32_t bits;
+ uint8_t decoded[3];
switch ((binary_state)p->binary) {
case NOT_BINARY:
append_bytes(str, cur, (size_t)(end - cur));
@@ -1197,9 +1197,9 @@ static int append_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
goto b64_byte3;
p->base64_buffer |= bits;
bits = p->base64_buffer;
- decoded[0] = (gpr_uint8)(bits >> 16);
- decoded[1] = (gpr_uint8)(bits >> 8);
- decoded[2] = (gpr_uint8)(bits);
+ decoded[0] = (uint8_t)(bits >> 16);
+ decoded[1] = (uint8_t)(bits >> 8);
+ decoded[2] = (uint8_t)(bits);
append_bytes(str, decoded, 3);
goto b64_byte0;
}
@@ -1208,9 +1208,9 @@ static int append_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* append a null terminator to a string */
static int finish_str(grpc_chttp2_hpack_parser *p) {
- gpr_uint8 terminator = 0;
- gpr_uint8 decoded[2];
- gpr_uint32 bits;
+ uint8_t terminator = 0;
+ uint8_t decoded[2];
+ uint32_t bits;
grpc_chttp2_hpack_parser_string *str = p->parsing.str;
switch ((binary_state)p->binary) {
case NOT_BINARY:
@@ -1227,7 +1227,7 @@ static int finish_str(grpc_chttp2_hpack_parser *p) {
bits & 0xffff);
return 0;
}
- decoded[0] = (gpr_uint8)(bits >> 16);
+ decoded[0] = (uint8_t)(bits >> 16);
append_bytes(str, decoded, 1);
break;
case B64_BYTE3:
@@ -1237,8 +1237,8 @@ static int finish_str(grpc_chttp2_hpack_parser *p) {
bits & 0xff);
return 0;
}
- decoded[0] = (gpr_uint8)(bits >> 16);
- decoded[1] = (gpr_uint8)(bits >> 8);
+ decoded[0] = (uint8_t)(bits >> 16);
+ decoded[1] = (uint8_t)(bits >> 8);
append_bytes(str, decoded, 2);
break;
}
@@ -1248,12 +1248,12 @@ static int finish_str(grpc_chttp2_hpack_parser *p) {
}
/* decode a nibble from a huffman encoded stream */
-static int huff_nibble(grpc_chttp2_hpack_parser *p, gpr_uint8 nibble) {
- gpr_int16 emit = emit_sub_tbl[16 * emit_tbl[p->huff_state] + nibble];
- gpr_int16 next = next_sub_tbl[16 * next_tbl[p->huff_state] + nibble];
+static int huff_nibble(grpc_chttp2_hpack_parser *p, uint8_t nibble) {
+ int16_t emit = emit_sub_tbl[16 * emit_tbl[p->huff_state] + nibble];
+ int16_t next = next_sub_tbl[16 * next_tbl[p->huff_state] + nibble];
if (emit != -1) {
if (emit >= 0 && emit < 256) {
- gpr_uint8 c = (gpr_uint8)emit;
+ uint8_t c = (uint8_t)emit;
if (!append_string(p, &c, (&c) + 1)) return 0;
} else {
assert(emit == 256);
@@ -1264,8 +1264,8 @@ static int huff_nibble(grpc_chttp2_hpack_parser *p, gpr_uint8 nibble) {
}
/* decode full bytes from a huffman encoded stream */
-static int add_huff_bytes(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int add_huff_bytes(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
for (; cur != end; ++cur) {
if (!huff_nibble(p, *cur >> 4) || !huff_nibble(p, *cur & 0xf)) return 0;
}
@@ -1274,8 +1274,8 @@ static int add_huff_bytes(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
/* decode some string bytes based on the current decoding mode
(huffman or not) */
-static int add_str_bytes(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int add_str_bytes(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
if (p->huff) {
return add_huff_bytes(p, cur, end);
} else {
@@ -1284,8 +1284,8 @@ static int add_str_bytes(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
}
/* parse a string - tries to do large chunks at a time */
-static int parse_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_string(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
size_t remaining = p->strlen - p->strgot;
size_t given = (size_t)(end - cur);
if (remaining <= given) {
@@ -1293,16 +1293,16 @@ static int parse_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
parse_next(p, cur + remaining, end);
} else {
if (!add_str_bytes(p, cur, cur + given)) return 0;
- GPR_ASSERT(given <= GPR_UINT32_MAX - p->strgot);
- p->strgot += (gpr_uint32)given;
+ GPR_ASSERT(given <= UINT32_MAX - p->strgot);
+ p->strgot += (uint32_t)given;
p->state = parse_string;
return 1;
}
}
/* begin parsing a string - performs setup, calls parse_string */
-static int begin_parse_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end, gpr_uint8 binary,
+static int begin_parse_string(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end, uint8_t binary,
grpc_chttp2_hpack_parser_string *str) {
p->strgot = 0;
str->length = 0;
@@ -1313,8 +1313,8 @@ static int begin_parse_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
}
/* parse the key string */
-static int parse_key_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+static int parse_key_string(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end) {
return begin_parse_string(p, cur, end, NOT_BINARY, &p->key);
}
@@ -1340,8 +1340,8 @@ static is_binary_header is_binary_indexed_header(grpc_chttp2_hpack_parser *p) {
}
/* parse the value string */
-static int parse_value_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
- const gpr_uint8 *end, is_binary_header type) {
+static int parse_value_string(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
+ const uint8_t *end, is_binary_header type) {
switch (type) {
case BINARY_HEADER:
return begin_parse_string(p, cur, end, B64_BYTE0, &p->value);
@@ -1355,14 +1355,14 @@ static int parse_value_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
}
static int parse_value_string_with_indexed_key(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+ const uint8_t *cur,
+ const uint8_t *end) {
return parse_value_string(p, cur, end, is_binary_indexed_header(p));
}
static int parse_value_string_with_literal_key(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *cur,
- const gpr_uint8 *end) {
+ const uint8_t *cur,
+ const uint8_t *end) {
return parse_value_string(p, cur, end, is_binary_literal_header(p));
}
@@ -1398,7 +1398,7 @@ void grpc_chttp2_hpack_parser_destroy(grpc_chttp2_hpack_parser *p) {
}
int grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *beg, const gpr_uint8 *end) {
+ const uint8_t *beg, const uint8_t *end) {
/* TODO(ctiller): limit the distance of end from beg, and perform multiple
steps in the event of a large chunk of data to limit
stack space usage when no tail call optimization is
diff --git a/src/core/transport/chttp2/hpack_parser.h b/src/core/transport/chttp2/hpack_parser.h
index bd36357124..1ad0c64fb9 100644
--- a/src/core/transport/chttp2/hpack_parser.h
+++ b/src/core/transport/chttp2/hpack_parser.h
@@ -45,13 +45,13 @@
typedef struct grpc_chttp2_hpack_parser grpc_chttp2_hpack_parser;
typedef int (*grpc_chttp2_hpack_parser_state)(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *beg,
- const gpr_uint8 *end);
+ const uint8_t *beg,
+ const uint8_t *end);
typedef struct {
char *str;
- gpr_uint32 length;
- gpr_uint32 capacity;
+ uint32_t length;
+ uint32_t capacity;
} grpc_chttp2_hpack_parser_string;
struct grpc_chttp2_hpack_parser {
@@ -67,31 +67,31 @@ struct grpc_chttp2_hpack_parser {
grpc_chttp2_hpack_parser_state after_prioritization;
/* the value we're currently parsing */
union {
- gpr_uint32 *value;
+ uint32_t *value;
grpc_chttp2_hpack_parser_string *str;
} parsing;
/* string parameters for each chunk */
grpc_chttp2_hpack_parser_string key;
grpc_chttp2_hpack_parser_string value;
/* parsed index */
- gpr_uint32 index;
+ uint32_t index;
/* length of source bytes for the currently parsing string */
- gpr_uint32 strlen;
+ uint32_t strlen;
/* number of source bytes read for the currently parsing string */
- gpr_uint32 strgot;
+ uint32_t strgot;
/* huffman decoding state */
- gpr_int16 huff_state;
+ int16_t huff_state;
/* is the string being decoded binary? */
- gpr_uint8 binary;
+ uint8_t binary;
/* is the current string huffman encoded? */
- gpr_uint8 huff;
+ uint8_t huff;
/* is a dynamic table update allowed? */
- gpr_uint8 dynamic_table_update_allowed;
+ uint8_t dynamic_table_update_allowed;
/* set by higher layers, used by grpc_chttp2_header_parser_parse to signal
it should append a metadata boundary at the end of frame */
- gpr_uint8 is_boundary;
- gpr_uint8 is_eof;
- gpr_uint32 base64_buffer;
+ uint8_t is_boundary;
+ uint8_t is_eof;
+ uint32_t base64_buffer;
/* hpack table */
grpc_chttp2_hptbl table;
@@ -104,7 +104,7 @@ void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser *p);
/* returns 1 on success, 0 on error */
int grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser *p,
- const gpr_uint8 *beg, const gpr_uint8 *end);
+ const uint8_t *beg, const uint8_t *end);
/* wraps grpc_chttp2_hpack_parser_parse to provide a frame level parser for
the transport */
diff --git a/src/core/transport/chttp2/hpack_table.c b/src/core/transport/chttp2/hpack_table.c
index 59060daad3..f1ce3b84fd 100644
--- a/src/core/transport/chttp2/hpack_table.c
+++ b/src/core/transport/chttp2/hpack_table.c
@@ -171,7 +171,7 @@ static struct {
{"www-authenticate", ""},
};
-static gpr_uint32 entries_for_bytes(gpr_uint32 bytes) {
+static uint32_t entries_for_bytes(uint32_t bytes) {
return (bytes + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD - 1) /
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
}
@@ -204,7 +204,7 @@ void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl *tbl) {
}
grpc_mdelem *grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
- gpr_uint32 tbl_index) {
+ uint32_t tbl_index) {
/* Static table comes first, just return an entry from it */
if (tbl_index <= GRPC_CHTTP2_LAST_STATIC_ENTRY) {
return tbl->static_ents[tbl_index - 1];
@@ -212,7 +212,7 @@ grpc_mdelem *grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
/* Otherwise, find the value in the list of valid entries */
tbl_index -= (GRPC_CHTTP2_LAST_STATIC_ENTRY + 1);
if (tbl_index < tbl->num_ents) {
- gpr_uint32 offset =
+ uint32_t offset =
(tbl->num_ents - 1u - tbl_index + tbl->first_ent) % tbl->cap_entries;
return tbl->ents[offset];
}
@@ -227,15 +227,15 @@ static void evict1(grpc_chttp2_hptbl *tbl) {
GPR_SLICE_LENGTH(first_ent->value->slice) +
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
GPR_ASSERT(elem_bytes <= tbl->mem_used);
- tbl->mem_used -= (gpr_uint32)elem_bytes;
+ tbl->mem_used -= (uint32_t)elem_bytes;
tbl->first_ent = ((tbl->first_ent + 1) % tbl->cap_entries);
tbl->num_ents--;
GRPC_MDELEM_UNREF(first_ent);
}
-static void rebuild_ents(grpc_chttp2_hptbl *tbl, gpr_uint32 new_cap) {
+static void rebuild_ents(grpc_chttp2_hptbl *tbl, uint32_t new_cap) {
grpc_mdelem **ents = gpr_malloc(sizeof(*ents) * new_cap);
- gpr_uint32 i;
+ uint32_t i;
for (i = 0; i < tbl->num_ents; i++) {
ents[i] = tbl->ents[(tbl->first_ent + i) % tbl->cap_entries];
@@ -247,7 +247,7 @@ static void rebuild_ents(grpc_chttp2_hptbl *tbl, gpr_uint32 new_cap) {
}
void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl *tbl,
- gpr_uint32 max_bytes) {
+ uint32_t max_bytes) {
if (tbl->max_bytes == max_bytes) {
return;
}
@@ -259,7 +259,7 @@ void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl *tbl,
}
int grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl *tbl,
- gpr_uint32 bytes) {
+ uint32_t bytes) {
if (tbl->current_table_bytes == bytes) {
return 1;
}
@@ -278,7 +278,7 @@ int grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl *tbl,
if (tbl->max_entries > tbl->cap_entries) {
rebuild_ents(tbl, GPR_MAX(tbl->max_entries, 2 * tbl->cap_entries));
} else if (tbl->max_entries < tbl->cap_entries / 3) {
- gpr_uint32 new_cap = GPR_MAX(tbl->max_entries, 16u);
+ uint32_t new_cap = GPR_MAX(tbl->max_entries, 16u);
if (new_cap != tbl->cap_entries) {
rebuild_ents(tbl, new_cap);
}
@@ -328,14 +328,14 @@ int grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl, grpc_mdelem *md) {
/* update accounting values */
tbl->num_ents++;
- tbl->mem_used += (gpr_uint32)elem_bytes;
+ tbl->mem_used += (uint32_t)elem_bytes;
return 1;
}
grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
const grpc_chttp2_hptbl *tbl, grpc_mdelem *md) {
grpc_chttp2_hptbl_find_result r = {0, 0};
- gpr_uint32 i;
+ uint32_t i;
/* See if the string is in the static table */
for (i = 0; i < GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) {
@@ -348,8 +348,8 @@ grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
/* Scan the dynamic table */
for (i = 0; i < tbl->num_ents; i++) {
- gpr_uint32 idx =
- (gpr_uint32)(tbl->num_ents - i + GRPC_CHTTP2_LAST_STATIC_ENTRY);
+ uint32_t idx =
+ (uint32_t)(tbl->num_ents - i + GRPC_CHTTP2_LAST_STATIC_ENTRY);
grpc_mdelem *ent = tbl->ents[(tbl->first_ent + i) % tbl->cap_entries];
if (md->key != ent->key) continue;
r.index = idx;
diff --git a/src/core/transport/chttp2/hpack_table.h b/src/core/transport/chttp2/hpack_table.h
index a173eec30c..e7431255fc 100644
--- a/src/core/transport/chttp2/hpack_table.h
+++ b/src/core/transport/chttp2/hpack_table.h
@@ -60,21 +60,21 @@
/* hpack decoder table */
typedef struct {
/* the first used entry in ents */
- gpr_uint32 first_ent;
+ uint32_t first_ent;
/* how many entries are in the table */
- gpr_uint32 num_ents;
+ uint32_t num_ents;
/* the amount of memory used by the table, according to the hpack algorithm */
- gpr_uint32 mem_used;
+ uint32_t mem_used;
/* the max memory allowed to be used by the table, according to the hpack
algorithm */
- gpr_uint32 max_bytes;
+ uint32_t max_bytes;
/* the currently agreed size of the table, according to the hpack algorithm */
- gpr_uint32 current_table_bytes;
+ uint32_t current_table_bytes;
/* Maximum number of entries we could possibly fit in the table, given defined
overheads */
- gpr_uint32 max_entries;
+ uint32_t max_entries;
/* Number of entries allocated in ents */
- gpr_uint32 cap_entries;
+ uint32_t cap_entries;
/* a circular buffer of headers - this is stored in the opposite order to
what hpack specifies, in order to simplify table management a little...
meaning lookups need to SUBTRACT from the end position */
@@ -86,20 +86,20 @@ typedef struct {
void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl *tbl);
void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl *tbl);
void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl *tbl,
- gpr_uint32 max_bytes);
+ uint32_t max_bytes);
int grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl *tbl,
- gpr_uint32 bytes);
+ uint32_t bytes);
/* lookup a table entry based on its hpack index */
grpc_mdelem *grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
- gpr_uint32 index);
+ uint32_t index);
/* add a table entry to the index */
int grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl,
grpc_mdelem *md) GRPC_MUST_USE_RESULT;
/* Find a key/value pair in the table... returns the index in the table of the
most similar entry, or 0 if the value was not found */
typedef struct {
- gpr_uint32 index;
+ uint32_t index;
int has_value;
} grpc_chttp2_hptbl_find_result;
grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
diff --git a/src/core/transport/chttp2/internal.h b/src/core/transport/chttp2/internal.h
index 43b3adb9d3..0b0fccfcd4 100644
--- a/src/core/transport/chttp2/internal.h
+++ b/src/core/transport/chttp2/internal.h
@@ -141,7 +141,7 @@ typedef enum {
/* Outstanding ping request data */
typedef struct grpc_chttp2_outstanding_ping {
- gpr_uint8 id[8];
+ uint8_t id[8];
grpc_closure *on_recv;
struct grpc_chttp2_outstanding_ping *next;
struct grpc_chttp2_outstanding_ping *prev;
@@ -152,6 +152,7 @@ struct grpc_chttp2_incoming_byte_stream {
grpc_byte_stream base;
gpr_refcount refs;
struct grpc_chttp2_incoming_byte_stream *next_message;
+ int failed;
grpc_chttp2_transport *transport;
grpc_chttp2_stream *stream;
@@ -166,46 +167,46 @@ typedef struct {
gpr_slice_buffer qbuf;
/** window available for us to send to peer */
- gpr_int64 outgoing_window;
+ int64_t outgoing_window;
/** window available to announce to peer */
- gpr_int64 announce_incoming_window;
+ int64_t announce_incoming_window;
/** how much window would we like to have for incoming_window */
- gpr_uint32 connection_window_target;
+ uint32_t connection_window_target;
/** have we seen a goaway */
- gpr_uint8 seen_goaway;
+ uint8_t seen_goaway;
/** have we sent a goaway */
- gpr_uint8 sent_goaway;
+ uint8_t sent_goaway;
/** is this transport a client? */
- gpr_uint8 is_client;
+ uint8_t is_client;
/** are the local settings dirty and need to be sent? */
- gpr_uint8 dirtied_local_settings;
+ uint8_t dirtied_local_settings;
/** have local settings been sent? */
- gpr_uint8 sent_local_settings;
+ uint8_t sent_local_settings;
/** bitmask of setting indexes to send out */
- gpr_uint32 force_send_settings;
+ uint32_t force_send_settings;
/** settings values */
- gpr_uint32 settings[GRPC_NUM_SETTING_SETS][GRPC_CHTTP2_NUM_SETTINGS];
+ uint32_t settings[GRPC_NUM_SETTING_SETS][GRPC_CHTTP2_NUM_SETTINGS];
/** what is the next stream id to be allocated by this peer?
copied to next_stream_id in parsing when parsing commences */
- gpr_uint32 next_stream_id;
+ uint32_t next_stream_id;
/** how far to lookahead in a stream? */
- gpr_uint32 stream_lookahead;
+ uint32_t stream_lookahead;
/** last received stream id */
- gpr_uint32 last_incoming_stream_id;
+ uint32_t last_incoming_stream_id;
/** pings awaiting responses */
grpc_chttp2_outstanding_ping pings;
/** next payload for an outgoing ping */
- gpr_uint64 ping_counter;
+ uint64_t ping_counter;
/** concurrent stream count: updated when not parsing,
so this is a strict over-estimation on the client */
- gpr_uint32 concurrent_stream_count;
+ uint32_t concurrent_stream_count;
} grpc_chttp2_transport_global;
typedef struct {
@@ -213,29 +214,29 @@ typedef struct {
gpr_slice_buffer outbuf;
/** hpack encoding */
grpc_chttp2_hpack_compressor hpack_compressor;
- gpr_int64 outgoing_window;
+ int64_t outgoing_window;
/** is this a client? */
- gpr_uint8 is_client;
+ uint8_t is_client;
/** callback for when writing is done */
grpc_closure done_cb;
} grpc_chttp2_transport_writing;
struct grpc_chttp2_transport_parsing {
/** is this transport a client? (boolean) */
- gpr_uint8 is_client;
+ uint8_t is_client;
/** were settings updated? */
- gpr_uint8 settings_updated;
+ uint8_t settings_updated;
/** was a settings ack received? */
- gpr_uint8 settings_ack_received;
+ uint8_t settings_ack_received;
/** was a goaway frame received? */
- gpr_uint8 goaway_received;
+ uint8_t goaway_received;
/** the last sent max_table_size setting */
- gpr_uint32 last_sent_max_table_size;
+ uint32_t last_sent_max_table_size;
/** initial window change */
- gpr_int64 initial_window_update;
+ int64_t initial_window_update;
/** data to write later - after parsing */
gpr_slice_buffer qbuf;
@@ -252,20 +253,20 @@ struct grpc_chttp2_transport_parsing {
grpc_chttp2_goaway_parser goaway_parser;
/** window available for peer to send to us */
- gpr_int64 incoming_window;
+ int64_t incoming_window;
/** next stream id available at the time of beginning parsing */
- gpr_uint32 next_stream_id;
- gpr_uint32 last_incoming_stream_id;
+ uint32_t next_stream_id;
+ uint32_t last_incoming_stream_id;
/* deframing */
grpc_chttp2_deframe_transport_state deframe_state;
- gpr_uint8 incoming_frame_type;
- gpr_uint8 incoming_frame_flags;
- gpr_uint8 header_eof;
- gpr_uint32 expect_continuation_stream_id;
- gpr_uint32 incoming_frame_size;
- gpr_uint32 incoming_stream_id;
+ uint8_t incoming_frame_type;
+ uint8_t incoming_frame_flags;
+ uint8_t header_eof;
+ uint32_t expect_continuation_stream_id;
+ uint32_t incoming_frame_size;
+ uint32_t incoming_stream_id;
/* active parser */
void *parser_data;
@@ -276,14 +277,14 @@ struct grpc_chttp2_transport_parsing {
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
/* received settings */
- gpr_uint32 settings[GRPC_CHTTP2_NUM_SETTINGS];
+ uint32_t settings[GRPC_CHTTP2_NUM_SETTINGS];
/* goaway data */
grpc_status_code goaway_error;
- gpr_uint32 goaway_last_stream_index;
+ uint32_t goaway_last_stream_index;
gpr_slice goaway_text;
- gpr_int64 outgoing_window;
+ int64_t outgoing_window;
};
struct grpc_chttp2_transport {
@@ -298,17 +299,17 @@ struct grpc_chttp2_transport {
gpr_mu mu;
/** is the transport destroying itself? */
- gpr_uint8 destroying;
+ uint8_t destroying;
/** has the upper layer closed the transport? */
- gpr_uint8 closed;
+ uint8_t closed;
/** is a thread currently writing */
- gpr_uint8 writing_active;
+ uint8_t writing_active;
/** is a thread currently parsing */
- gpr_uint8 parsing_active;
+ uint8_t parsing_active;
/** is there a read request to the endpoint outstanding? */
- gpr_uint8 endpoint_reading;
+ uint8_t endpoint_reading;
/** various lists of streams */
grpc_chttp2_stream_list lists[STREAM_LIST_COUNT];
@@ -357,20 +358,20 @@ struct grpc_chttp2_transport {
typedef struct {
/** HTTP2 stream id for this stream, or zero if one has not been assigned */
- gpr_uint32 id;
+ uint32_t id;
/** window available for us to send to peer */
- gpr_int64 outgoing_window;
+ int64_t outgoing_window;
/** The number of bytes the upper layers have offered to receive.
As the upper layer offers more bytes, this value increases.
As bytes are read, this value decreases. */
- gpr_uint32 max_recv_bytes;
+ uint32_t max_recv_bytes;
/** The number of bytes the upper layer has offered to read but we have
not yet announced to HTTP2 flow control.
As the upper layers offer to read more bytes, this value increases.
As we advertise incoming flow control window, this value decreases. */
- gpr_uint32 unannounced_incoming_window_for_parse;
- gpr_uint32 unannounced_incoming_window_for_writing;
+ uint32_t unannounced_incoming_window_for_parse;
+ uint32_t unannounced_incoming_window_for_writing;
/** things the upper layers would like to send */
grpc_metadata_batch *send_initial_metadata;
grpc_closure *send_initial_metadata_finished;
@@ -389,18 +390,18 @@ typedef struct {
/** when the application requests writes be closed, the write_closed is
'queued'; when the close is flow controlled into the send path, we are
'sending' it; when the write has been performed it is 'sent' */
- gpr_uint8 write_closed;
+ uint8_t write_closed;
/** is this stream reading half-closed (boolean) */
- gpr_uint8 read_closed;
+ uint8_t read_closed;
/** is this stream in the stream map? (boolean) */
- gpr_uint8 in_stream_map;
+ uint8_t in_stream_map;
/** has this stream seen an error? if 1, then pending incoming frames
can be thrown away */
- gpr_uint8 seen_error;
+ uint8_t seen_error;
- gpr_uint8 published_initial_metadata;
- gpr_uint8 published_trailing_metadata;
- gpr_uint8 faked_trailing_metadata;
+ uint8_t published_initial_metadata;
+ uint8_t published_trailing_metadata;
+ uint8_t faked_trailing_metadata;
grpc_chttp2_incoming_metadata_buffer received_initial_metadata;
grpc_chttp2_incoming_metadata_buffer received_trailing_metadata;
@@ -410,19 +411,19 @@ typedef struct {
typedef struct {
/** HTTP2 stream id for this stream, or zero if one has not been assigned */
- gpr_uint32 id;
- gpr_uint8 fetching;
- gpr_uint8 sent_initial_metadata;
- gpr_uint8 sent_message;
- gpr_uint8 sent_trailing_metadata;
- gpr_uint8 read_closed;
+ uint32_t id;
+ uint8_t fetching;
+ uint8_t sent_initial_metadata;
+ uint8_t sent_message;
+ uint8_t sent_trailing_metadata;
+ uint8_t read_closed;
/** send this initial metadata */
grpc_metadata_batch *send_initial_metadata;
grpc_byte_stream *send_message;
grpc_metadata_batch *send_trailing_metadata;
- gpr_int64 outgoing_window;
+ int64_t outgoing_window;
/** how much window should we announce? */
- gpr_uint32 announce_window;
+ uint32_t announce_window;
gpr_slice_buffer flow_controlled_buffer;
gpr_slice fetching_slice;
size_t stream_fetched;
@@ -431,27 +432,27 @@ typedef struct {
struct grpc_chttp2_stream_parsing {
/** HTTP2 stream id for this stream, or zero if one has not been assigned */
- gpr_uint32 id;
+ uint32_t id;
/** has this stream received a close */
- gpr_uint8 received_close;
+ uint8_t received_close;
/** saw a rst_stream */
- gpr_uint8 saw_rst_stream;
+ uint8_t saw_rst_stream;
/** how many header frames have we received? */
- gpr_uint8 header_frames_received;
+ uint8_t header_frames_received;
/** which metadata did we get (on this parse) */
- gpr_uint8 got_metadata_on_parse[2];
+ uint8_t got_metadata_on_parse[2];
/** should we raise the seen_error flag in transport_global */
- gpr_uint8 seen_error;
+ uint8_t seen_error;
/** window available for peer to send to us */
- gpr_int64 incoming_window;
+ int64_t incoming_window;
/** parsing state for data frames */
grpc_chttp2_data_parser data_parser;
/** reason give to rst_stream */
- gpr_uint32 rst_stream_reason;
+ uint32_t rst_stream_reason;
/** amount of window given */
- gpr_int64 outgoing_window;
+ int64_t outgoing_window;
/** number of bytes received - reset at end of parse thread execution */
- gpr_int64 received_bytes;
+ int64_t received_bytes;
/** incoming metadata */
grpc_chttp2_incoming_metadata_buffer metadata_buffer[2];
@@ -464,7 +465,7 @@ struct grpc_chttp2_stream {
grpc_chttp2_stream_parsing parsing;
grpc_chttp2_stream_link links[STREAM_LIST_COUNT];
- gpr_uint8 included[STREAM_LIST_COUNT];
+ uint8_t included[STREAM_LIST_COUNT];
};
/** Transport writing call flow:
@@ -565,6 +566,9 @@ void grpc_chttp2_list_add_stalled_by_transport(
int grpc_chttp2_list_pop_stalled_by_transport(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global **stream_global);
+void grpc_chttp2_list_remove_stalled_by_transport(
+ grpc_chttp2_transport_global *transport_global,
+ grpc_chttp2_stream_global *stream_global);
void grpc_chttp2_list_add_unannounced_incoming_window_available(
grpc_chttp2_transport_global *transport_global,
@@ -593,14 +597,14 @@ int grpc_chttp2_list_pop_closed_waiting_for_writing(
grpc_chttp2_stream_global **stream_global);
grpc_chttp2_stream_parsing *grpc_chttp2_parsing_lookup_stream(
- grpc_chttp2_transport_parsing *transport_parsing, gpr_uint32 id);
+ grpc_chttp2_transport_parsing *transport_parsing, uint32_t id);
grpc_chttp2_stream_parsing *grpc_chttp2_parsing_accept_stream(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
- gpr_uint32 id);
+ uint32_t id);
void grpc_chttp2_add_incoming_goaway(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global,
- gpr_uint32 goaway_error, gpr_slice goaway_text);
+ uint32_t goaway_error, gpr_slice goaway_text);
void grpc_chttp2_register_stream(grpc_chttp2_transport *t,
grpc_chttp2_stream *s);
@@ -706,8 +710,7 @@ void grpc_chttp2_flowctl_trace(const char *file, int line, const char *phase,
grpc_chttp2_flowctl_op op, const char *context1,
const char *var1, const char *context2,
const char *var2, int is_client,
- gpr_uint32 stream_id, gpr_int64 val1,
- gpr_int64 val2);
+ uint32_t stream_id, int64_t val1, int64_t val2);
void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport_global *transport_global,
@@ -742,16 +745,17 @@ void grpc_chttp2_stream_unref(grpc_exec_ctx *exec_ctx,
grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
- grpc_chttp2_stream_parsing *stream_parsing, gpr_uint32 frame_size,
- gpr_uint32 flags, grpc_chttp2_incoming_frame_queue *add_to_queue);
+ grpc_chttp2_stream_parsing *stream_parsing, uint32_t frame_size,
+ uint32_t flags, grpc_chttp2_incoming_frame_queue *add_to_queue);
void grpc_chttp2_incoming_byte_stream_push(grpc_exec_ctx *exec_ctx,
grpc_chttp2_incoming_byte_stream *bs,
gpr_slice slice);
void grpc_chttp2_incoming_byte_stream_finished(
- grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs);
+ grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs, int success,
+ int from_parsing_thread);
void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport_parsing *parsing,
- const gpr_uint8 *opaque_8bytes);
+ const uint8_t *opaque_8bytes);
#endif
diff --git a/src/core/transport/chttp2/parsing.c b/src/core/transport/chttp2/parsing.c
index 7604e7b681..8fdebd7f13 100644
--- a/src/core/transport/chttp2/parsing.c
+++ b/src/core/transport/chttp2/parsing.c
@@ -126,7 +126,7 @@ void grpc_chttp2_publish_reads(
if (transport_parsing->settings_ack_received) {
memcpy(transport_global->settings[GRPC_ACKED_SETTINGS],
transport_global->settings[GRPC_SENT_SETTINGS],
- GRPC_CHTTP2_NUM_SETTINGS * sizeof(gpr_uint32));
+ GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t));
transport_parsing->settings_ack_received = 0;
transport_global->sent_local_settings = 0;
}
@@ -135,7 +135,7 @@ void grpc_chttp2_publish_reads(
published later */
if (transport_parsing->goaway_received) {
grpc_chttp2_add_incoming_goaway(exec_ctx, transport_global,
- (gpr_uint32)transport_parsing->goaway_error,
+ (uint32_t)transport_parsing->goaway_error,
transport_parsing->goaway_text);
transport_parsing->goaway_text = gpr_empty_slice();
transport_parsing->goaway_received = 0;
@@ -155,8 +155,8 @@ void grpc_chttp2_publish_reads(
if (transport_parsing->incoming_window <
transport_global->connection_window_target * 3 / 4) {
- gpr_int64 announce_bytes = transport_global->connection_window_target -
- transport_parsing->incoming_window;
+ int64_t announce_bytes = transport_global->connection_window_target -
+ transport_parsing->incoming_window;
GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("parsed", transport_global,
announce_incoming_window, announce_bytes);
GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("parsed", transport_parsing,
@@ -181,7 +181,7 @@ void grpc_chttp2_publish_reads(
grpc_chttp2_list_add_writable_stream(transport_global, stream_global);
}
- stream_global->max_recv_bytes -= (gpr_uint32)GPR_MIN(
+ stream_global->max_recv_bytes -= (uint32_t)GPR_MIN(
stream_global->max_recv_bytes, stream_parsing->received_bytes);
stream_parsing->received_bytes = 0;
@@ -245,9 +245,9 @@ void grpc_chttp2_publish_reads(
int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport_parsing *transport_parsing,
gpr_slice slice) {
- gpr_uint8 *beg = GPR_SLICE_START_PTR(slice);
- gpr_uint8 *end = GPR_SLICE_END_PTR(slice);
- gpr_uint8 *cur = beg;
+ uint8_t *beg = GPR_SLICE_START_PTR(slice);
+ uint8_t *end = GPR_SLICE_END_PTR(slice);
+ uint8_t *cur = beg;
if (cur == end) return 1;
@@ -284,7 +284,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
"at byte %d",
GRPC_CHTTP2_CLIENT_CONNECT_STRING[transport_parsing
->deframe_state],
- (int)(gpr_uint8)GRPC_CHTTP2_CLIENT_CONNECT_STRING
+ (int)(uint8_t)GRPC_CHTTP2_CLIENT_CONNECT_STRING
[transport_parsing->deframe_state],
*cur, (int)*cur, transport_parsing->deframe_state);
return 0;
@@ -299,7 +299,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
dts_fh_0:
case GRPC_DTS_FH_0:
GPR_ASSERT(cur < end);
- transport_parsing->incoming_frame_size = ((gpr_uint32)*cur) << 16;
+ transport_parsing->incoming_frame_size = ((uint32_t)*cur) << 16;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_1;
return 1;
@@ -307,7 +307,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
/* fallthrough */
case GRPC_DTS_FH_1:
GPR_ASSERT(cur < end);
- transport_parsing->incoming_frame_size |= ((gpr_uint32)*cur) << 8;
+ transport_parsing->incoming_frame_size |= ((uint32_t)*cur) << 8;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_2;
return 1;
@@ -339,7 +339,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
/* fallthrough */
case GRPC_DTS_FH_5:
GPR_ASSERT(cur < end);
- transport_parsing->incoming_stream_id = (((gpr_uint32)*cur) & 0x7f) << 24;
+ transport_parsing->incoming_stream_id = (((uint32_t)*cur) & 0x7f) << 24;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_6;
return 1;
@@ -347,7 +347,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
/* fallthrough */
case GRPC_DTS_FH_6:
GPR_ASSERT(cur < end);
- transport_parsing->incoming_stream_id |= ((gpr_uint32)*cur) << 16;
+ transport_parsing->incoming_stream_id |= ((uint32_t)*cur) << 16;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_7;
return 1;
@@ -355,7 +355,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
/* fallthrough */
case GRPC_DTS_FH_7:
GPR_ASSERT(cur < end);
- transport_parsing->incoming_stream_id |= ((gpr_uint32)*cur) << 8;
+ transport_parsing->incoming_stream_id |= ((uint32_t)*cur) << 8;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_8;
return 1;
@@ -363,7 +363,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
/* fallthrough */
case GRPC_DTS_FH_8:
GPR_ASSERT(cur < end);
- transport_parsing->incoming_stream_id |= ((gpr_uint32)*cur);
+ transport_parsing->incoming_stream_id |= ((uint32_t)*cur);
transport_parsing->deframe_state = GRPC_DTS_FRAME;
if (!init_frame_parser(exec_ctx, transport_parsing)) {
return 0;
@@ -390,7 +390,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
/* fallthrough */
case GRPC_DTS_FRAME:
GPR_ASSERT(cur < end);
- if ((gpr_uint32)(end - cur) == transport_parsing->incoming_frame_size) {
+ if ((uint32_t)(end - cur) == transport_parsing->incoming_frame_size) {
if (!parse_frame_slice(exec_ctx, transport_parsing,
gpr_slice_sub_no_ref(slice, (size_t)(cur - beg),
(size_t)(end - beg)),
@@ -400,7 +400,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
transport_parsing->deframe_state = GRPC_DTS_FH_0;
transport_parsing->incoming_stream = NULL;
return 1;
- } else if ((gpr_uint32)(end - cur) >
+ } else if ((uint32_t)(end - cur) >
transport_parsing->incoming_frame_size) {
size_t cur_offset = (size_t)(cur - beg);
if (!parse_frame_slice(
@@ -421,7 +421,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
0)) {
return 0;
}
- transport_parsing->incoming_frame_size -= (gpr_uint32)(end - cur);
+ transport_parsing->incoming_frame_size -= (uint32_t)(end - cur);
return 1;
}
GPR_UNREACHABLE_CODE(return 0);
@@ -488,14 +488,14 @@ static int init_skip_frame_parser(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
int is_header) {
if (is_header) {
- gpr_uint8 is_eoh = transport_parsing->expect_continuation_stream_id != 0;
+ uint8_t is_eoh = transport_parsing->expect_continuation_stream_id != 0;
transport_parsing->parser = grpc_chttp2_header_parser_parse;
transport_parsing->parser_data = &transport_parsing->hpack_parser;
transport_parsing->hpack_parser.on_header = skip_header;
transport_parsing->hpack_parser.on_header_user_data = NULL;
transport_parsing->hpack_parser.is_boundary = is_eoh;
transport_parsing->hpack_parser.is_eof =
- (gpr_uint8)(is_eoh ? transport_parsing->header_eof : 0);
+ (uint8_t)(is_eoh ? transport_parsing->header_eof : 0);
} else {
transport_parsing->parser = skip_parser;
}
@@ -512,7 +512,7 @@ void grpc_chttp2_parsing_become_skip_parser(
static grpc_chttp2_parse_error update_incoming_window(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing) {
- gpr_uint32 incoming_frame_size = transport_parsing->incoming_frame_size;
+ uint32_t incoming_frame_size = transport_parsing->incoming_frame_size;
if (incoming_frame_size > transport_parsing->incoming_window) {
gpr_log(GPR_ERROR, "frame of size %d overflows incoming window of %d",
transport_parsing->incoming_frame_size,
@@ -652,8 +652,8 @@ static void on_trailing_header(void *tp, grpc_mdelem *md) {
static int init_header_frame_parser(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
int is_continuation) {
- gpr_uint8 is_eoh = (transport_parsing->incoming_frame_flags &
- GRPC_CHTTP2_DATA_FLAG_END_HEADERS) != 0;
+ uint8_t is_eoh = (transport_parsing->incoming_frame_flags &
+ GRPC_CHTTP2_DATA_FLAG_END_HEADERS) != 0;
int via_accept = 0;
grpc_chttp2_stream_parsing *stream_parsing;
@@ -738,7 +738,7 @@ static int init_header_frame_parser(
transport_parsing->hpack_parser.on_header_user_data = transport_parsing;
transport_parsing->hpack_parser.is_boundary = is_eoh;
transport_parsing->hpack_parser.is_eof =
- (gpr_uint8)(is_eoh ? transport_parsing->header_eof : 0);
+ (uint8_t)(is_eoh ? transport_parsing->header_eof : 0);
if (!is_continuation && (transport_parsing->incoming_frame_flags &
GRPC_CHTTP2_FLAG_HAS_PRIORITY)) {
grpc_chttp2_hpack_parser_set_has_priority(&transport_parsing->hpack_parser);
@@ -829,7 +829,7 @@ static int init_settings_frame_parser(
}
/*
-static int is_window_update_legal(gpr_int64 window_update, gpr_int64 window) {
+static int is_window_update_legal(int64_t window_update, int64_t window) {
return window + window_update < MAX_WINDOW;
}
*/
diff --git a/src/core/transport/chttp2/stream_lists.c b/src/core/transport/chttp2/stream_lists.c
index 49f951d08b..273a513e2f 100644
--- a/src/core/transport/chttp2/stream_lists.c
+++ b/src/core/transport/chttp2/stream_lists.c
@@ -333,6 +333,14 @@ int grpc_chttp2_list_pop_stalled_by_transport(
return r;
}
+void grpc_chttp2_list_remove_stalled_by_transport(
+ grpc_chttp2_transport_global *transport_global,
+ grpc_chttp2_stream_global *stream_global) {
+ stream_list_maybe_remove(TRANSPORT_FROM_GLOBAL(transport_global),
+ STREAM_FROM_GLOBAL(stream_global),
+ GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT);
+}
+
void grpc_chttp2_list_add_closed_waiting_for_parsing(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global) {
diff --git a/src/core/transport/chttp2/stream_map.c b/src/core/transport/chttp2/stream_map.c
index c983105abb..555a16fb72 100644
--- a/src/core/transport/chttp2/stream_map.c
+++ b/src/core/transport/chttp2/stream_map.c
@@ -42,7 +42,7 @@
void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map *map,
size_t initial_capacity) {
GPR_ASSERT(initial_capacity > 1);
- map->keys = gpr_malloc(sizeof(gpr_uint32) * initial_capacity);
+ map->keys = gpr_malloc(sizeof(uint32_t) * initial_capacity);
map->values = gpr_malloc(sizeof(void *) * initial_capacity);
map->count = 0;
map->free = 0;
@@ -54,7 +54,7 @@ void grpc_chttp2_stream_map_destroy(grpc_chttp2_stream_map *map) {
gpr_free(map->values);
}
-static size_t compact(gpr_uint32 *keys, void **values, size_t count) {
+static size_t compact(uint32_t *keys, void **values, size_t count) {
size_t i, out;
for (i = 0, out = 0; i < count; i++) {
@@ -68,11 +68,11 @@ static size_t compact(gpr_uint32 *keys, void **values, size_t count) {
return out;
}
-void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, gpr_uint32 key,
+void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, uint32_t key,
void *value) {
size_t count = map->count;
size_t capacity = map->capacity;
- gpr_uint32 *keys = map->keys;
+ uint32_t *keys = map->keys;
void **values = map->values;
GPR_ASSERT(count == 0 || keys[count - 1] < key);
@@ -86,7 +86,7 @@ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, gpr_uint32 key,
/* resize when less than 25% of the table is free, because compaction
won't help much */
map->capacity = capacity = 3 * capacity / 2;
- map->keys = keys = gpr_realloc(keys, capacity * sizeof(gpr_uint32));
+ map->keys = keys = gpr_realloc(keys, capacity * sizeof(uint32_t));
map->values = values = gpr_realloc(values, capacity * sizeof(void *));
}
}
@@ -119,10 +119,10 @@ void grpc_chttp2_stream_map_move_into(grpc_chttp2_stream_map *src,
/* if dst doesn't have capacity, resize */
if (dst->count + src->count > dst->capacity) {
dst->capacity = GPR_MAX(dst->capacity * 3 / 2, dst->count + src->count);
- dst->keys = gpr_realloc(dst->keys, dst->capacity * sizeof(gpr_uint32));
+ dst->keys = gpr_realloc(dst->keys, dst->capacity * sizeof(uint32_t));
dst->values = gpr_realloc(dst->values, dst->capacity * sizeof(void *));
}
- memcpy(dst->keys + dst->count, src->keys, src->count * sizeof(gpr_uint32));
+ memcpy(dst->keys + dst->count, src->keys, src->count * sizeof(uint32_t));
memcpy(dst->values + dst->count, src->values, src->count * sizeof(void *));
dst->count += src->count;
dst->free += src->free;
@@ -130,13 +130,13 @@ void grpc_chttp2_stream_map_move_into(grpc_chttp2_stream_map *src,
src->free = 0;
}
-static void **find(grpc_chttp2_stream_map *map, gpr_uint32 key) {
+static void **find(grpc_chttp2_stream_map *map, uint32_t key) {
size_t min_idx = 0;
size_t max_idx = map->count;
size_t mid_idx;
- gpr_uint32 *keys = map->keys;
+ uint32_t *keys = map->keys;
void **values = map->values;
- gpr_uint32 mid_key;
+ uint32_t mid_key;
if (max_idx == 0) return NULL;
@@ -158,8 +158,7 @@ static void **find(grpc_chttp2_stream_map *map, gpr_uint32 key) {
return NULL;
}
-void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map,
- gpr_uint32 key) {
+void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map, uint32_t key) {
void **pvalue = find(map, key);
void *out = NULL;
if (pvalue != NULL) {
@@ -175,7 +174,7 @@ void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map,
return out;
}
-void *grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, gpr_uint32 key) {
+void *grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, uint32_t key) {
void **pvalue = find(map, key);
return pvalue != NULL ? *pvalue : NULL;
}
@@ -185,7 +184,7 @@ size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map *map) {
}
void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map *map,
- void (*f)(void *user_data, gpr_uint32 key,
+ void (*f)(void *user_data, uint32_t key,
void *value),
void *user_data) {
size_t i;
diff --git a/src/core/transport/chttp2/stream_map.h b/src/core/transport/chttp2/stream_map.h
index 71b0582054..7a0e45fab2 100644
--- a/src/core/transport/chttp2/stream_map.h
+++ b/src/core/transport/chttp2/stream_map.h
@@ -38,14 +38,14 @@
#include <stddef.h>
-/* Data structure to map a gpr_uint32 to a data object (represented by a void*)
+/* Data structure to map a uint32_t to a data object (represented by a void*)
Represented as a sorted array of keys, and a corresponding array of values.
Lookups are performed with binary search.
Adds are restricted to strictly higher keys than previously seen (this is
guaranteed by http2). */
typedef struct {
- gpr_uint32 *keys;
+ uint32_t *keys;
void **values;
size_t count;
size_t free;
@@ -58,27 +58,26 @@ void grpc_chttp2_stream_map_destroy(grpc_chttp2_stream_map *map);
/* Add a new key: given http2 semantics, new keys must always be greater than
existing keys - this is asserted */
-void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, gpr_uint32 key,
+void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, uint32_t key,
void *value);
/* Delete an existing key - returns the previous value of the key if it existed,
or NULL otherwise */
-void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map,
- gpr_uint32 key);
+void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map, uint32_t key);
/* Move all elements of src into dst */
void grpc_chttp2_stream_map_move_into(grpc_chttp2_stream_map *src,
grpc_chttp2_stream_map *dst);
/* Return an existing key, or NULL if it does not exist */
-void *grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, gpr_uint32 key);
+void *grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, uint32_t key);
/* How many (populated) entries are in the stream map? */
size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map *map);
/* Callback on each stream */
void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map *map,
- void (*f)(void *user_data, gpr_uint32 key,
+ void (*f)(void *user_data, uint32_t key,
void *value),
void *user_data);
diff --git a/src/core/transport/chttp2/timeout_encoding.c b/src/core/transport/chttp2/timeout_encoding.c
index 7ec8b4e8bf..8cbf987a42 100644
--- a/src/core/transport/chttp2/timeout_encoding.c
+++ b/src/core/transport/chttp2/timeout_encoding.c
@@ -39,12 +39,12 @@
#include <grpc/support/port_platform.h>
#include "src/core/support/string.h"
-static gpr_int64 round_up(gpr_int64 x, gpr_int64 divisor) {
+static int64_t round_up(int64_t x, int64_t divisor) {
return (x / divisor + (x % divisor != 0)) * divisor;
}
/* round an integer up to the next value with three significant figures */
-static gpr_int64 round_up_to_three_sig_figs(gpr_int64 x) {
+static int64_t round_up_to_three_sig_figs(int64_t x) {
if (x < 1000) return x;
if (x < 10000) return round_up(x, 10);
if (x < 100000) return round_up(x, 100);
@@ -58,13 +58,13 @@ static gpr_int64 round_up_to_three_sig_figs(gpr_int64 x) {
/* encode our minimum viable timeout value */
static void enc_tiny(char *buffer) { memcpy(buffer, "1n", 3); }
-static void enc_ext(char *buffer, gpr_int64 value, char ext) {
- int n = gpr_int64toa(value, buffer);
+static void enc_ext(char *buffer, int64_t value, char ext) {
+ int n = int64_ttoa(value, buffer);
buffer[n] = ext;
buffer[n + 1] = 0;
}
-static void enc_seconds(char *buffer, gpr_int64 sec) {
+static void enc_seconds(char *buffer, int64_t sec) {
if (sec % 3600 == 0) {
enc_ext(buffer, sec / 3600, 'H');
} else if (sec % 60 == 0) {
@@ -74,7 +74,7 @@ static void enc_seconds(char *buffer, gpr_int64 sec) {
}
}
-static void enc_nanos(char *buffer, gpr_int64 x) {
+static void enc_nanos(char *buffer, int64_t x) {
x = round_up_to_three_sig_figs(x);
if (x < 100000) {
if (x % 1000 == 0) {
@@ -98,7 +98,7 @@ static void enc_nanos(char *buffer, gpr_int64 x) {
}
}
-static void enc_micros(char *buffer, gpr_int64 x) {
+static void enc_micros(char *buffer, int64_t x) {
x = round_up_to_three_sig_figs(x);
if (x < 100000) {
if (x % 1000 == 0) {
@@ -124,7 +124,7 @@ void grpc_chttp2_encode_timeout(gpr_timespec timeout, char *buffer) {
enc_nanos(buffer, timeout.tv_nsec);
} else if (timeout.tv_sec < 1000 && timeout.tv_nsec != 0) {
enc_micros(buffer,
- (gpr_int64)(timeout.tv_sec * 1000000) +
+ (int64_t)(timeout.tv_sec * 1000000) +
(timeout.tv_nsec / 1000 + (timeout.tv_nsec % 1000 != 0)));
} else {
enc_seconds(buffer, timeout.tv_sec + (timeout.tv_nsec != 0));
@@ -137,15 +137,15 @@ static int is_all_whitespace(const char *p) {
}
int grpc_chttp2_decode_timeout(const char *buffer, gpr_timespec *timeout) {
- gpr_uint32 x = 0;
- const gpr_uint8 *p = (const gpr_uint8 *)buffer;
+ uint32_t x = 0;
+ const uint8_t *p = (const uint8_t *)buffer;
int have_digit = 0;
/* skip whitespace */
for (; *p == ' '; p++)
;
/* decode numeric part */
for (; *p >= '0' && *p <= '9'; p++) {
- gpr_uint32 xp = x * 10u + (gpr_uint32)*p - (gpr_uint32)'0';
+ uint32_t xp = x * 10u + (uint32_t)*p - (uint32_t)'0';
have_digit = 1;
if (xp < x) {
*timeout = gpr_inf_future(GPR_CLOCK_REALTIME);
diff --git a/src/core/transport/chttp2/varint.c b/src/core/transport/chttp2/varint.c
index 056f68047b..1cc235e989 100644
--- a/src/core/transport/chttp2/varint.c
+++ b/src/core/transport/chttp2/varint.c
@@ -33,7 +33,7 @@
#include "src/core/transport/chttp2/varint.h"
-gpr_uint32 grpc_chttp2_hpack_varint_length(gpr_uint32 tail_value) {
+uint32_t grpc_chttp2_hpack_varint_length(uint32_t tail_value) {
if (tail_value < (1 << 7)) {
return 2;
} else if (tail_value < (1 << 14)) {
@@ -47,20 +47,19 @@ gpr_uint32 grpc_chttp2_hpack_varint_length(gpr_uint32 tail_value) {
}
}
-void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value,
- gpr_uint8* target,
- gpr_uint32 tail_length) {
+void grpc_chttp2_hpack_write_varint_tail(uint32_t tail_value, uint8_t* target,
+ uint32_t tail_length) {
switch (tail_length) {
case 5:
- target[4] = (gpr_uint8)((tail_value >> 28) | 0x80);
+ target[4] = (uint8_t)((tail_value >> 28) | 0x80);
case 4:
- target[3] = (gpr_uint8)((tail_value >> 21) | 0x80);
+ target[3] = (uint8_t)((tail_value >> 21) | 0x80);
case 3:
- target[2] = (gpr_uint8)((tail_value >> 14) | 0x80);
+ target[2] = (uint8_t)((tail_value >> 14) | 0x80);
case 2:
- target[1] = (gpr_uint8)((tail_value >> 7) | 0x80);
+ target[1] = (uint8_t)((tail_value >> 7) | 0x80);
case 1:
- target[0] = (gpr_uint8)((tail_value) | 0x80);
+ target[0] = (uint8_t)((tail_value) | 0x80);
}
target[tail_length - 1] &= 0x7f;
}
diff --git a/src/core/transport/chttp2/varint.h b/src/core/transport/chttp2/varint.h
index 5acb15d032..2d92b6693e 100644
--- a/src/core/transport/chttp2/varint.h
+++ b/src/core/transport/chttp2/varint.h
@@ -41,17 +41,16 @@
/* length of a value that needs varint tail encoding (it's bigger than can be
bitpacked into the opcode byte) - returned value includes the length of the
opcode byte */
-gpr_uint32 grpc_chttp2_hpack_varint_length(gpr_uint32 tail_value);
+uint32_t grpc_chttp2_hpack_varint_length(uint32_t tail_value);
-void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value,
- gpr_uint8* target,
- gpr_uint32 tail_length);
+void grpc_chttp2_hpack_write_varint_tail(uint32_t tail_value, uint8_t* target,
+ uint32_t tail_length);
/* maximum value that can be bitpacked with the opcode if the opcode has a
prefix
of length prefix_bits */
#define GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \
- ((gpr_uint32)((1 << (8 - (prefix_bits))) - 1))
+ ((uint32_t)((1 << (8 - (prefix_bits))) - 1))
/* length required to bitpack a value */
#define GRPC_CHTTP2_VARINT_LENGTH(n, prefix_bits) \
@@ -62,12 +61,12 @@ void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value,
#define GRPC_CHTTP2_WRITE_VARINT(n, prefix_bits, prefix_or, target, length) \
do { \
- gpr_uint8* tgt = target; \
+ uint8_t* tgt = target; \
if ((length) == 1u) { \
- (tgt)[0] = (gpr_uint8)((prefix_or) | (n)); \
+ (tgt)[0] = (uint8_t)((prefix_or) | (n)); \
} else { \
(tgt)[0] = \
- (prefix_or) | (gpr_uint8)GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \
+ (prefix_or) | (uint8_t)GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \
grpc_chttp2_hpack_write_varint_tail( \
(n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits), (tgt) + 1, (length)-1); \
} \
diff --git a/src/core/transport/chttp2/writing.c b/src/core/transport/chttp2/writing.c
index b5ca42d69c..fdad05b5fb 100644
--- a/src/core/transport/chttp2/writing.c
+++ b/src/core/transport/chttp2/writing.c
@@ -80,7 +80,7 @@ int grpc_chttp2_unlocking_check_writes(
(according to available window sizes) and add to the output buffer */
while (grpc_chttp2_list_pop_writable_stream(
transport_global, transport_writing, &stream_global, &stream_writing)) {
- gpr_uint8 sent_initial_metadata;
+ uint8_t sent_initial_metadata;
stream_writing->id = stream_global->id;
stream_writing->read_closed = stream_global->read_closed;
@@ -103,15 +103,15 @@ int grpc_chttp2_unlocking_check_writes(
if (sent_initial_metadata) {
if (stream_global->send_message != NULL) {
gpr_slice hdr = gpr_slice_malloc(5);
- gpr_uint8 *p = GPR_SLICE_START_PTR(hdr);
- gpr_uint32 len = stream_global->send_message->length;
+ uint8_t *p = GPR_SLICE_START_PTR(hdr);
+ uint32_t len = stream_global->send_message->length;
GPR_ASSERT(stream_writing->send_message == NULL);
p[0] = (stream_global->send_message->flags &
GRPC_WRITE_INTERNAL_COMPRESS) != 0;
- p[1] = (gpr_uint8)(len >> 24);
- p[2] = (gpr_uint8)(len >> 16);
- p[3] = (gpr_uint8)(len >> 8);
- p[4] = (gpr_uint8)(len);
+ p[1] = (uint8_t)(len >> 24);
+ p[2] = (uint8_t)(len >> 16);
+ p[3] = (uint8_t)(len >> 8);
+ p[4] = (uint8_t)(len);
gpr_slice_buffer_add(&stream_writing->flow_controlled_buffer, hdr);
if (stream_global->send_message->length > 0) {
stream_writing->send_message = stream_global->send_message;
@@ -160,8 +160,8 @@ int grpc_chttp2_unlocking_check_writes(
/* if the grpc_chttp2_transport is ready to send a window update, do so here
also; 3/4 is a magic number that will likely get tuned soon */
if (transport_global->announce_incoming_window > 0) {
- gpr_uint32 announced = (gpr_uint32)GPR_MIN(
- transport_global->announce_incoming_window, GPR_UINT32_MAX);
+ uint32_t announced = (uint32_t)GPR_MIN(
+ transport_global->announce_incoming_window, UINT32_MAX);
GRPC_CHTTP2_FLOW_DEBIT_TRANSPORT("write", transport_global,
announce_incoming_window, announced);
gpr_slice_buffer_add(&transport_writing->outbuf,
@@ -200,10 +200,10 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx,
while (
grpc_chttp2_list_pop_writing_stream(transport_writing, &stream_writing)) {
- gpr_uint32 max_outgoing =
- (gpr_uint32)GPR_MIN(GRPC_CHTTP2_MAX_PAYLOAD_LENGTH,
- GPR_MIN(stream_writing->outgoing_window,
- transport_writing->outgoing_window));
+ uint32_t max_outgoing =
+ (uint32_t)GPR_MIN(GRPC_CHTTP2_MAX_PAYLOAD_LENGTH,
+ GPR_MIN(stream_writing->outgoing_window,
+ transport_writing->outgoing_window));
/* send initial metadata if it's available */
if (stream_writing->send_initial_metadata != NULL) {
grpc_chttp2_encode_header(
@@ -215,7 +215,7 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx,
/* send any window updates */
if (stream_writing->announce_window > 0 &&
stream_writing->send_initial_metadata == NULL) {
- gpr_uint32 announce = stream_writing->announce_window;
+ uint32_t announce = stream_writing->announce_window;
gpr_slice_buffer_add(
&transport_writing->outbuf,
grpc_chttp2_window_update_create(stream_writing->id,
@@ -247,7 +247,7 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx,
/* send any body bytes */
if (stream_writing->flow_controlled_buffer.length > 0) {
if (max_outgoing > 0) {
- gpr_uint32 send_bytes = (gpr_uint32)GPR_MIN(
+ uint32_t send_bytes = (uint32_t)GPR_MIN(
max_outgoing, stream_writing->flow_controlled_buffer.length);
int is_last_data_frame =
stream_writing->send_message == NULL &&