|
|
|
@ -112,14 +112,14 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( |
|
|
|
|
char* msg; |
|
|
|
|
|
|
|
|
|
if (cur == end) { |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch (p->state) { |
|
|
|
|
case GRPC_CHTTP2_DATA_ERROR: |
|
|
|
|
p->state = GRPC_CHTTP2_DATA_ERROR; |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
return GRPC_ERROR_REF(p->error); |
|
|
|
|
case GRPC_CHTTP2_DATA_FH_0: |
|
|
|
|
s->stats.incoming.framing_bytes++; |
|
|
|
@ -144,12 +144,12 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( |
|
|
|
|
p->error = |
|
|
|
|
grpc_error_set_int(p->error, GRPC_ERROR_INT_OFFSET, cur - beg); |
|
|
|
|
p->state = GRPC_CHTTP2_DATA_ERROR; |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
return GRPC_ERROR_REF(p->error); |
|
|
|
|
} |
|
|
|
|
if (++cur == end) { |
|
|
|
|
p->state = GRPC_CHTTP2_DATA_FH_1; |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
/* fallthrough */ |
|
|
|
@ -158,7 +158,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( |
|
|
|
|
p->frame_size = (static_cast<uint32_t>(*cur)) << 24; |
|
|
|
|
if (++cur == end) { |
|
|
|
|
p->state = GRPC_CHTTP2_DATA_FH_2; |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
/* fallthrough */ |
|
|
|
@ -167,7 +167,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( |
|
|
|
|
p->frame_size |= (static_cast<uint32_t>(*cur)) << 16; |
|
|
|
|
if (++cur == end) { |
|
|
|
|
p->state = GRPC_CHTTP2_DATA_FH_3; |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
/* fallthrough */ |
|
|
|
@ -176,7 +176,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( |
|
|
|
|
p->frame_size |= (static_cast<uint32_t>(*cur)) << 8; |
|
|
|
|
if (++cur == end) { |
|
|
|
|
p->state = GRPC_CHTTP2_DATA_FH_4; |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
/* fallthrough */ |
|
|
|
@ -207,14 +207,14 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( |
|
|
|
|
grpc_slice_buffer_sub_first(slices, static_cast<size_t>(cur - beg), |
|
|
|
|
static_cast<size_t>(end - beg)); |
|
|
|
|
} else { |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
} |
|
|
|
|
return GRPC_ERROR_NONE; |
|
|
|
|
case GRPC_CHTTP2_DATA_FRAME: { |
|
|
|
|
GPR_ASSERT(p->parsing_frame != nullptr); |
|
|
|
|
GPR_ASSERT(slice_out != nullptr); |
|
|
|
|
if (cur == end) { |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
uint32_t remaining = static_cast<uint32_t>(end - cur); |
|
|
|
@ -225,17 +225,17 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( |
|
|
|
|
grpc_slice_sub(*slice, static_cast<size_t>(cur - beg), |
|
|
|
|
static_cast<size_t>(end - beg)), |
|
|
|
|
slice_out))) { |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
return error; |
|
|
|
|
} |
|
|
|
|
if (GRPC_ERROR_NONE != |
|
|
|
|
(error = p->parsing_frame->Finished(GRPC_ERROR_NONE, true))) { |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
return error; |
|
|
|
|
} |
|
|
|
|
p->parsing_frame = nullptr; |
|
|
|
|
p->state = GRPC_CHTTP2_DATA_FH_0; |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
return GRPC_ERROR_NONE; |
|
|
|
|
} else if (remaining < p->frame_size) { |
|
|
|
|
s->stats.incoming.data_bytes += remaining; |
|
|
|
@ -247,7 +247,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( |
|
|
|
|
return error; |
|
|
|
|
} |
|
|
|
|
p->frame_size -= remaining; |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
return GRPC_ERROR_NONE; |
|
|
|
|
} else { |
|
|
|
|
GPR_ASSERT(remaining > p->frame_size); |
|
|
|
@ -258,12 +258,12 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( |
|
|
|
|
*slice, static_cast<size_t>(cur - beg), |
|
|
|
|
static_cast<size_t>(cur + p->frame_size - beg)), |
|
|
|
|
slice_out)) { |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
return error; |
|
|
|
|
} |
|
|
|
|
if (GRPC_ERROR_NONE != |
|
|
|
|
(error = p->parsing_frame->Finished(GRPC_ERROR_NONE, true))) { |
|
|
|
|
grpc_slice_buffer_consume_first(slices); |
|
|
|
|
grpc_slice_buffer_remove_first(slices); |
|
|
|
|
return error; |
|
|
|
|
} |
|
|
|
|
p->parsing_frame = nullptr; |
|
|
|
|