diff options
author | 2017-04-02 18:18:51 -0700 | |
---|---|---|
committer | 2017-04-02 18:18:51 -0700 | |
commit | 0fa217dfb938166c0442dc023db8095264f77e77 (patch) | |
tree | c948466ba176a2053e07e961ec5a05e50b9a518e /src/core/ext/transport | |
parent | f570f96edaa895621f7c8d57737e0f79c3f24cf9 (diff) |
clang-format
Diffstat (limited to 'src/core/ext/transport')
-rw-r--r-- | src/core/ext/transport/chttp2/transport/chttp2_transport.c | 123 | ||||
-rw-r--r-- | src/core/ext/transport/chttp2/transport/internal.h | 35 | ||||
-rw-r--r-- | src/core/ext/transport/chttp2/transport/parsing.c | 22 |
3 files changed, 100 insertions, 80 deletions
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 176382cb10..d3a4f35ea4 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -115,9 +115,9 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, static void incoming_byte_stream_destroy_locked(grpc_exec_ctx *exec_ctx, void *byte_stream, grpc_error *error_ignored); -static void incoming_byte_stream_publish_error(grpc_exec_ctx *exec_ctx, - grpc_chttp2_incoming_byte_stream *bs, - grpc_error *error); +static void incoming_byte_stream_publish_error( + grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs, + grpc_error *error); static void incoming_byte_stream_unref(grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs); @@ -161,12 +161,10 @@ static void finish_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg, static void keepalive_watchdog_fired_locked(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error); -static grpc_error *deframe_unprocessed_incoming_frames(grpc_exec_ctx *exec_ctx, - grpc_chttp2_data_parser *p, - grpc_chttp2_stream *s, - grpc_slice_buffer *slices, - grpc_slice *slice_out, - grpc_byte_stream **stream_out); +static grpc_error *deframe_unprocessed_incoming_frames( + grpc_exec_ctx *exec_ctx, grpc_chttp2_data_parser *p, grpc_chttp2_stream *s, + grpc_slice_buffer *slices, grpc_slice *slice_out, + grpc_byte_stream **stream_out); static void reset_byte_stream(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error); @@ -615,7 +613,8 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt, grpc_slice_buffer_init(&s->unprocessed_incoming_frames_buffer); grpc_slice_buffer_init(&s->frame_storage); s->pending_byte_stream = false; - grpc_closure_init(&s->reset_byte_stream, reset_byte_stream, s, grpc_combiner_scheduler(t->combiner, false)); + grpc_closure_init(&s->reset_byte_stream, reset_byte_stream, s, + grpc_combiner_scheduler(t->combiner, false)); GRPC_CHTTP2_REF_TRANSPORT(t, "stream"); @@ -1520,7 +1519,8 @@ void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_exec_ctx *exec_ctx, if (s->seen_error) { grpc_slice_buffer_reset_and_unref(&s->frame_storage); if (!s->pending_byte_stream) { - grpc_slice_buffer_reset_and_unref(&s->unprocessed_incoming_frames_buffer); + grpc_slice_buffer_reset_and_unref( + &s->unprocessed_incoming_frames_buffer); } } grpc_chttp2_incoming_metadata_buffer_publish( @@ -1539,21 +1539,26 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx *exec_ctx, if (s->final_metadata_requested && s->seen_error) { grpc_slice_buffer_reset_and_unref(&s->frame_storage); if (!s->pending_byte_stream) { - grpc_slice_buffer_reset_and_unref(&s->unprocessed_incoming_frames_buffer); + grpc_slice_buffer_reset_and_unref( + &s->unprocessed_incoming_frames_buffer); } } if (!s->pending_byte_stream) { while (s->unprocessed_incoming_frames_buffer.length > 0 || s->frame_storage.length > 0) { if (s->unprocessed_incoming_frames_buffer.length == 0) { - grpc_slice_buffer_swap(&s->unprocessed_incoming_frames_buffer, &s->frame_storage); + grpc_slice_buffer_swap(&s->unprocessed_incoming_frames_buffer, + &s->frame_storage); } /* error handling ok? */ - error = deframe_unprocessed_incoming_frames(exec_ctx, &s->data_parser, s, &s->unprocessed_incoming_frames_buffer, NULL, s->recv_message); + error = deframe_unprocessed_incoming_frames( + exec_ctx, &s->data_parser, s, + &s->unprocessed_incoming_frames_buffer, NULL, s->recv_message); if (error != GRPC_ERROR_NONE) { s->seen_error = true; grpc_slice_buffer_reset_and_unref(&s->frame_storage); - grpc_slice_buffer_reset_and_unref(&s->unprocessed_incoming_frames_buffer); + grpc_slice_buffer_reset_and_unref( + &s->unprocessed_incoming_frames_buffer); break; } else if (*s->recv_message != NULL) { break; @@ -1578,7 +1583,8 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx *exec_ctx, if (s->seen_error) { grpc_slice_buffer_reset_and_unref(&s->frame_storage); if (!s->pending_byte_stream) { - grpc_slice_buffer_reset_and_unref(&s->unprocessed_incoming_frames_buffer); + grpc_slice_buffer_reset_and_unref( + &s->unprocessed_incoming_frames_buffer); } } if (s->read_closed && s->frame_storage.length == 0 && @@ -2263,16 +2269,15 @@ static void reset_byte_stream(grpc_exec_ctx *exec_ctx, void *arg, grpc_closure_sched(exec_ctx, s->on_next, GRPC_ERROR_REF(error)); s->on_next = NULL; GRPC_ERROR_UNREF(s->byte_stream_error); - grpc_chttp2_cancel_stream(exec_ctx, s->t, s, - GRPC_ERROR_REF(error)); + grpc_chttp2_cancel_stream(exec_ctx, s->t, s, GRPC_ERROR_REF(error)); s->byte_stream_error = error; } } static grpc_error *deframe_unprocessed_incoming_frames( - grpc_exec_ctx *exec_ctx, grpc_chttp2_data_parser *p, - grpc_chttp2_stream *s, grpc_slice_buffer *slices, - grpc_slice *slice_out, grpc_byte_stream **stream_out) { + grpc_exec_ctx *exec_ctx, grpc_chttp2_data_parser *p, grpc_chttp2_stream *s, + grpc_slice_buffer *slices, grpc_slice *slice_out, + grpc_byte_stream **stream_out) { grpc_error *error = GRPC_ERROR_NONE; grpc_chttp2_transport *t = s->t; @@ -2368,7 +2373,8 @@ static grpc_error *deframe_unprocessed_incoming_frames( exec_ctx, t, s, p->frame_size, message_flags); *stream_out = &p->parsing_frame->base; if (p->parsing_frame->remaining_bytes == 0) { - grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame, GRPC_ERROR_NONE, 1); + grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame, + GRPC_ERROR_NONE, 1); p->parsing_frame = NULL; p->state = GRPC_CHTTP2_DATA_FH_0; } else { @@ -2376,7 +2382,9 @@ static grpc_error *deframe_unprocessed_incoming_frames( } if (cur != end) { - grpc_slice_buffer_undo_take_first(&s->unprocessed_incoming_frames_buffer, grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg))); + grpc_slice_buffer_undo_take_first( + &s->unprocessed_incoming_frames_buffer, + grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg))); } grpc_slice_unref(slice); return GRPC_ERROR_NONE; @@ -2390,9 +2398,10 @@ static grpc_error *deframe_unprocessed_incoming_frames( uint32_t remaining = (uint32_t)(end - cur); if (remaining == p->frame_size) { if (GRPC_ERROR_NONE != (error = grpc_chttp2_incoming_byte_stream_push( - exec_ctx, p->parsing_frame, - grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)), - slice_out))) { + exec_ctx, p->parsing_frame, + grpc_slice_sub(slice, (size_t)(cur - beg), + (size_t)(end - beg)), + slice_out))) { grpc_slice_unref_internal(exec_ctx, slice); return error; } @@ -2405,9 +2414,10 @@ static grpc_error *deframe_unprocessed_incoming_frames( return GRPC_ERROR_NONE; } else if (remaining < p->frame_size) { if (GRPC_ERROR_NONE != (error = grpc_chttp2_incoming_byte_stream_push( - exec_ctx, p->parsing_frame, - grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)), - slice_out))) { + exec_ctx, p->parsing_frame, + grpc_slice_sub(slice, (size_t)(cur - beg), + (size_t)(end - beg)), + slice_out))) { return error; } p->frame_size -= remaining; @@ -2415,7 +2425,12 @@ static grpc_error *deframe_unprocessed_incoming_frames( return GRPC_ERROR_NONE; } else { GPR_ASSERT(remaining > p->frame_size); - if (GRPC_ERROR_NONE != (grpc_chttp2_incoming_byte_stream_push(exec_ctx, p->parsing_frame, grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(cur + p->frame_size - beg)), slice_out))) { + if (GRPC_ERROR_NONE != + (grpc_chttp2_incoming_byte_stream_push( + exec_ctx, p->parsing_frame, + grpc_slice_sub(slice, (size_t)(cur - beg), + (size_t)(cur + p->frame_size - beg)), + slice_out))) { grpc_slice_unref_internal(exec_ctx, slice); return error; } @@ -2424,7 +2439,9 @@ static grpc_error *deframe_unprocessed_incoming_frames( p->parsing_frame = NULL; p->state = GRPC_CHTTP2_DATA_FH_0; cur += p->frame_size; - grpc_slice_buffer_undo_take_first(&s->unprocessed_incoming_frames_buffer, grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg))); + grpc_slice_buffer_undo_take_first( + &s->unprocessed_incoming_frames_buffer, + grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg))); grpc_closure_sched(exec_ctx, &s->reset_byte_stream, GRPC_ERROR_NONE); grpc_slice_unref(slice); return GRPC_ERROR_NONE; @@ -2506,7 +2523,8 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx, GPR_ASSERT(s->unprocessed_incoming_frames_buffer.length == 0); if (s->frame_storage.length > 0) { - grpc_slice_buffer_swap(&s->frame_storage, &s->unprocessed_incoming_frames_buffer); + grpc_slice_buffer_swap(&s->frame_storage, + &s->unprocessed_incoming_frames_buffer); grpc_closure_sched(exec_ctx, bs->next_action.on_complete, GRPC_ERROR_NONE); } else if (s->byte_stream_error != GRPC_ERROR_NONE) { grpc_closure_sched(exec_ctx, bs->next_action.on_complete, @@ -2517,7 +2535,8 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx, } } else if (s->read_closed) { if (bs->remaining_bytes != 0) { - s->byte_stream_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message"); + s->byte_stream_error = + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message"); grpc_closure_sched(exec_ctx, bs->next_action.on_complete, GRPC_ERROR_REF(s->byte_stream_error)); if (s->data_parser.parsing_frame != NULL) { @@ -2549,11 +2568,11 @@ static int incoming_byte_stream_next(grpc_exec_ctx *exec_ctx, bs->next_action.max_size_hint = max_size_hint; bs->next_action.on_complete = on_complete; grpc_closure_sched( - exec_ctx, - grpc_closure_init( - &bs->next_action.closure, incoming_byte_stream_next_locked, bs, - grpc_combiner_scheduler(bs->transport->combiner, false)), - GRPC_ERROR_NONE); + exec_ctx, + grpc_closure_init( + &bs->next_action.closure, incoming_byte_stream_next_locked, bs, + grpc_combiner_scheduler(bs->transport->combiner, false)), + GRPC_ERROR_NONE); GPR_TIMER_END("incoming_byte_stream_next", 0); return 0; } @@ -2564,20 +2583,20 @@ static grpc_error *incoming_byte_stream_pull(grpc_exec_ctx *exec_ctx, grpc_slice *slice) { GPR_TIMER_BEGIN("incoming_byte_stream_pull", 0); grpc_chttp2_incoming_byte_stream *bs = - (grpc_chttp2_incoming_byte_stream *)byte_stream; + (grpc_chttp2_incoming_byte_stream *)byte_stream; grpc_chttp2_stream *s = bs->stream; if (s->unprocessed_incoming_frames_buffer.length > 0) { grpc_error *error = deframe_unprocessed_incoming_frames( - exec_ctx, &s->data_parser, s, &s->unprocessed_incoming_frames_buffer, - slice, NULL); + exec_ctx, &s->data_parser, s, &s->unprocessed_incoming_frames_buffer, + slice, NULL); if (error != GRPC_ERROR_NONE) { return error; } } else { - grpc_error *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message"); - grpc_closure_sched(exec_ctx, - &s->reset_byte_stream, GRPC_ERROR_REF(error)); + grpc_error *error = + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message"); + grpc_closure_sched(exec_ctx, &s->reset_byte_stream, GRPC_ERROR_REF(error)); return error; } GPR_TIMER_END("incoming_byte_stream_pull", 0); @@ -2623,17 +2642,16 @@ static void incoming_byte_stream_publish_error( s->byte_stream_error = GRPC_ERROR_REF(error); } -grpc_error *grpc_chttp2_incoming_byte_stream_push(grpc_exec_ctx *exec_ctx, - grpc_chttp2_incoming_byte_stream *bs, - grpc_slice slice, - grpc_slice *slice_out) { +grpc_error *grpc_chttp2_incoming_byte_stream_push( + grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs, + grpc_slice slice, grpc_slice *slice_out) { grpc_chttp2_stream *s = bs->stream; if (bs->remaining_bytes < GRPC_SLICE_LENGTH(slice)) { - grpc_error *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many bytes in stream"); + grpc_error *error = + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many bytes in stream"); - grpc_closure_sched(exec_ctx, - &s->reset_byte_stream, GRPC_ERROR_REF(error)); + grpc_closure_sched(exec_ctx, &s->reset_byte_stream, GRPC_ERROR_REF(error)); grpc_slice_unref_internal(exec_ctx, slice); return error; } else { @@ -2658,8 +2676,7 @@ grpc_error *grpc_chttp2_incoming_byte_stream_finished( gpr_mu_unlock(&bs->slice_mu); } if (error != GRPC_ERROR_NONE && reset_on_error) { - grpc_closure_sched(exec_ctx, - &s->reset_byte_stream, GRPC_ERROR_REF(error)); + grpc_closure_sched(exec_ctx, &s->reset_byte_stream, GRPC_ERROR_REF(error)); } incoming_byte_stream_unref(exec_ctx, bs); return error; diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index a43c825b70..a2deac6315 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -186,22 +186,23 @@ typedef struct grpc_chttp2_write_cb { struct grpc_chttp2_incoming_byte_stream { grpc_byte_stream base; gpr_refcount refs; - struct grpc_chttp2_incoming_byte_stream *next_message; /* unused; should be removed */ - bool push_closed; /* protected by slice_mu */ + struct grpc_chttp2_incoming_byte_stream + *next_message; /* unused; should be removed */ + bool push_closed; /* protected by slice_mu */ grpc_chttp2_transport *transport; /* immutable */ grpc_chttp2_stream *stream; /* immutable */ bool is_tail; /* immutable */ gpr_mu slice_mu; - grpc_slice_buffer slices; /* unused; should be removed */ - uint32_t remaining_bytes; /* guaranteed one thread access */ + grpc_slice_buffer slices; /* unused; should be removed */ + uint32_t remaining_bytes; /* guaranteed one thread access */ struct { grpc_closure closure; size_t max_size_hint; grpc_closure *on_complete; - } next_action; /* guaranteed one thread access */ + } next_action; /* guaranteed one thread access */ grpc_closure destroy_action; grpc_closure finished_action; }; @@ -431,8 +432,8 @@ struct grpc_chttp2_stream { uint32_t id; /** window available for us to send to peer, over or under the initial window - * size of the transport... ie: - * outgoing_window = outgoing_window_delta + transport.initial_window_size */ + * size of the transport... ie: + * outgoing_window = outgoing_window_delta + transport.initial_window_size */ int64_t outgoing_window_delta; /** things the upper layers would like to send */ grpc_metadata_batch *send_initial_metadata; @@ -484,12 +485,13 @@ struct grpc_chttp2_stream { grpc_chttp2_incoming_metadata_buffer metadata_buffer[2]; grpc_slice_buffer frame_storage; /* protected by t combiner */ - grpc_slice_buffer unprocessed_incoming_frames_buffer; /* guaranteed one thread access */ - grpc_closure *on_next; /* protected by t combiner */ - bool pending_byte_stream; /* protected by t combiner */ + grpc_slice_buffer + unprocessed_incoming_frames_buffer; /* guaranteed one thread access */ + grpc_closure *on_next; /* protected by t combiner */ + bool pending_byte_stream; /* protected by t combiner */ grpc_closure reset_byte_stream; grpc_error *byte_stream_error; /* protected by t combiner */ - bool received_last_frame; /* proected by t combiner */ + bool received_last_frame; /* proected by t combiner */ gpr_timespec deadline; @@ -502,7 +504,7 @@ struct grpc_chttp2_stream { * incoming_window = incoming_window_delta + transport.initial_window_size */ int64_t incoming_window_delta; /** parsing state for data frames */ - grpc_chttp2_data_parser data_parser; /* guaranteed one thread access */ + grpc_chttp2_data_parser data_parser; /* guaranteed one thread access */ /** number of bytes received - reset at end of parse thread execution */ int64_t received_bytes; @@ -617,7 +619,7 @@ extern int grpc_flowctl_trace; if (!(grpc_http_trace)) \ ; \ else \ - stmt + stmt typedef enum { GRPC_CHTTP2_FLOWCTL_MOVE, @@ -780,10 +782,9 @@ void grpc_chttp2_ref_transport(grpc_chttp2_transport *t); grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create( grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s, uint32_t frame_size, uint32_t flags); -grpc_error *grpc_chttp2_incoming_byte_stream_push(grpc_exec_ctx *exec_ctx, - grpc_chttp2_incoming_byte_stream *bs, - grpc_slice slice, - grpc_slice *slice_out); +grpc_error *grpc_chttp2_incoming_byte_stream_push( + grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs, + grpc_slice slice, grpc_slice *slice_out); grpc_error *grpc_chttp2_incoming_byte_stream_finished( grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs, grpc_error *error, int reset_on_error); diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 2c662b6721..bf1cf58cb2 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -230,10 +230,11 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx, case GRPC_DTS_FRAME: GPR_ASSERT(cur < end); if ((uint32_t)(end - cur) == t->incoming_frame_size) { - err = parse_frame_slice( - exec_ctx, t, grpc_slice_sub_no_ref(slice, (size_t)(cur - beg), - (size_t)(end - beg)), - 1); + err = + parse_frame_slice(exec_ctx, t, + grpc_slice_sub_no_ref(slice, (size_t)(cur - beg), + (size_t)(end - beg)), + 1); if (err != GRPC_ERROR_NONE) { return err; } @@ -254,10 +255,11 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx, t->incoming_stream = NULL; goto dts_fh_0; /* loop */ } else { - err = parse_frame_slice( - exec_ctx, t, grpc_slice_sub_no_ref(slice, (size_t)(cur - beg), - (size_t)(end - beg)), - 0); + err = + parse_frame_slice(exec_ctx, t, + grpc_slice_sub_no_ref(slice, (size_t)(cur - beg), + (size_t)(end - beg)), + 0); if (err != GRPC_ERROR_NONE) { return err; } @@ -458,8 +460,8 @@ static grpc_error *init_data_frame_parser(grpc_exec_ctx *exec_ctx, return init_skip_frame_parser(exec_ctx, t, 0); } if (err == GRPC_ERROR_NONE) { - err = grpc_chttp2_data_parser_begin_frame(&s->data_parser, - t->incoming_frame_flags, s->id, s); + err = grpc_chttp2_data_parser_begin_frame( + &s->data_parser, t->incoming_frame_flags, s->id, s); } error_handler: if (err == GRPC_ERROR_NONE) { |