From 04b06b7e325a8020c705ad9f4c3511f776d4b7b6 Mon Sep 17 00:00:00 2001 From: Muxi Yan <mxyan@google.com> Date: Mon, 13 Mar 2017 09:53:31 -0700 Subject: [PATCH] Add comments --- .../ext/transport/cronet/transport/cronet_transport.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 1759fe7ad2..fabfaf8a27 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -152,12 +152,16 @@ struct write_state { struct op_state { bool state_op_done[OP_NUM_OPS]; bool state_callback_received[OP_NUM_OPS]; + /* A non-zero gRPC status code has been seen */ bool fail_state; + /* Transport is discarding all buffered messages */ bool flush_read; bool flush_cronet_when_ready; bool pending_write_for_trailer; bool pending_send_message; + /* User requested RECV_TRAILING_METADATA */ bool pending_recv_trailing_metadata; + /* Cronet has not issued a callback of a bidirectional read */ bool pending_read_from_cronet; grpc_error *cancel_error; /* data structure for storing data coming from server */ @@ -260,6 +264,13 @@ static void null_and_maybe_free_read_buffer(stream_obj *s) { } static void maybe_flush_read(stream_obj *s) { + /* To enter flush read state (discarding all the buffered messages in + * transport layer), two conditions must be satisfied: 1) non-zero grpc status + * has been received, and 2) an op requesting the status code + * (RECV_TRAILING_METADATA) is issued by the user. (See + * doc/status_ordering.md) */ + /* Whenever the evaluation of any of the two condition is changed, we check + * whether we should enter the flush read state. */ if (s->state.pending_recv_trailing_metadata && s->state.fail_state) { if (!s->state.flush_read) { CRONET_LOG(GPR_DEBUG, "%p: Flush read", s); -- GitLab