From 020dbf2ef5d01f22791e20182ec0509767264ffe Mon Sep 17 00:00:00 2001 From: ncteisen Date: Fri, 14 Jul 2017 15:42:54 -0700 Subject: [PATCH] Move action func to chttp2 --- .../chttp2/transport/chttp2_transport.c | 35 +++++++++++++++++-- .../transport/chttp2/transport/flow_control.c | 31 ---------------- .../ext/transport/chttp2/transport/internal.h | 9 ++++- .../ext/transport/chttp2/transport/parsing.c | 2 +- 4 files changed, 42 insertions(+), 35 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 18b2725aae0..c48156b0690 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -1454,7 +1454,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op, if (!s->read_closed) { grpc_chttp2_flowctl_incoming_bs_update( &t->flow_control, &s->flow_control, 5, already_received); - grpc_chttp2_flowctl_act_on_action( + grpc_chttp2_act_on_flowctl_action( exec_ctx, grpc_chttp2_flowctl_get_action(&t->flow_control, &s->flow_control), t, s); @@ -2145,6 +2145,37 @@ static void end_all_the_calls(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, * INPUT PROCESSING - PARSING */ +void grpc_chttp2_act_on_flowctl_action(grpc_exec_ctx *exec_ctx, + grpc_chttp2_flowctl_action action, + grpc_chttp2_transport *t, + grpc_chttp2_stream *s) { + switch (action.send_stream_update) { + case GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED: + break; + case GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY: + grpc_chttp2_become_writable(exec_ctx, t, s, + GRPC_CHTTP2_STREAM_WRITE_INITIATE_COVERED, + "immediate stream flowctl"); + break; + case GRPC_CHTTP2_FLOWCTL_QUEUE_UPDATE: + grpc_chttp2_become_writable(exec_ctx, t, s, + GRPC_CHTTP2_STREAM_WRITE_PIGGYBACK, + "queue stream flowctl"); + break; + } + switch (action.send_transport_update) { + case GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED: + break; + case GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY: + grpc_chttp2_initiate_write(exec_ctx, t, "immediate transport flowctl"); + break; + // this is the same as no action b/c every time the transport enters the + // writing path it will maybe do an update + case GRPC_CHTTP2_FLOWCTL_QUEUE_UPDATE: + break; + } +} + static void update_bdp(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, double bdp_dbl) { // initial window size bounded [1,2^31-1], but we set the min to 128. @@ -2554,7 +2585,7 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_flowctl_incoming_bs_update(&t->flow_control, &s->flow_control, bs->next_action.max_size_hint, cur_length); - grpc_chttp2_flowctl_act_on_action( + grpc_chttp2_act_on_flowctl_action( exec_ctx, grpc_chttp2_flowctl_get_action(&t->flow_control, &s->flow_control), t, s); diff --git a/src/core/ext/transport/chttp2/transport/flow_control.c b/src/core/ext/transport/chttp2/transport/flow_control.c index a3e077fdf23..c9f7eabd43e 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.c +++ b/src/core/ext/transport/chttp2/transport/flow_control.c @@ -367,34 +367,3 @@ grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action( TRACEACTION(action); return action; } - -void grpc_chttp2_flowctl_act_on_action(grpc_exec_ctx* exec_ctx, - grpc_chttp2_flowctl_action action, - grpc_chttp2_transport* t, - grpc_chttp2_stream* s) { - switch (action.send_stream_update) { - case GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED: - break; - case GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY: - grpc_chttp2_become_writable(exec_ctx, t, s, - GRPC_CHTTP2_STREAM_WRITE_INITIATE_COVERED, - "immediate stream flowctl"); - break; - case GRPC_CHTTP2_FLOWCTL_QUEUE_UPDATE: - grpc_chttp2_become_writable(exec_ctx, t, s, - GRPC_CHTTP2_STREAM_WRITE_PIGGYBACK, - "queue stream flowctl"); - break; - } - switch (action.send_transport_update) { - case GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED: - break; - case GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY: - grpc_chttp2_initiate_write(exec_ctx, t, "immediate transport flowctl"); - break; - // this is the same as no action b/c every time the transport enters the - // writing path it will maybe do an update - case GRPC_CHTTP2_FLOWCTL_QUEUE_UPDATE: - break; - } -} diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 21ba75f4c08..bf0988bdd30 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -643,9 +643,13 @@ grpc_error *grpc_chttp2_flowctl_recv_data(grpc_chttp2_transport_flowctl *tfc, grpc_chttp2_stream_flowctl *sfc, int64_t incoming_frame_size); +// returns an announce if we should send a transport update to our peer, +// else returns zero uint32_t grpc_chttp2_flowctl_maybe_send_transport_update( grpc_chttp2_transport_flowctl *tfc); +// returns an announce if we should send a stream update to our peer, else +// returns zero uint32_t grpc_chttp2_flowctl_maybe_send_stream_update( grpc_chttp2_transport_flowctl *tfc, grpc_chttp2_stream_flowctl *sfc); @@ -682,11 +686,14 @@ typedef struct { grpc_chttp2_flowctl_urgency send_transport_update; } grpc_chttp2_flowctl_action; +// Reads the flow control data and returns and actionable struct that will tell +// chttp2 exactly what it needs to do grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action( const grpc_chttp2_transport_flowctl *tfc, const grpc_chttp2_stream_flowctl *sfc); -void grpc_chttp2_flowctl_act_on_action(grpc_exec_ctx *exec_ctx, +// Takes in a flow control action and performs all the needed operations. +void grpc_chttp2_act_on_flowctl_action(grpc_exec_ctx *exec_ctx, grpc_chttp2_flowctl_action action, grpc_chttp2_transport *t, grpc_chttp2_stream *s); diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index ec006ff0e1b..082541d6c36 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -357,7 +357,7 @@ static grpc_error *init_data_frame_parser(grpc_exec_ctx *exec_ctx, err = grpc_chttp2_flowctl_recv_data(&t->flow_control, s == NULL ? NULL : &s->flow_control, t->incoming_frame_size); - grpc_chttp2_flowctl_act_on_action( + grpc_chttp2_act_on_flowctl_action( exec_ctx, grpc_chttp2_flowctl_get_action( &t->flow_control, s == NULL ? NULL : &s->flow_control), t, s);