From 457984634e17f9a7bda664a07c0ea7420fb06924 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 14 Dec 2015 21:42:53 -0800 Subject: [PATCH] Better fix --- src/core/transport/chttp2/writing.c | 8 ++++---- src/core/transport/chttp2_transport.c | 29 ++++++--------------------- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/src/core/transport/chttp2/writing.c b/src/core/transport/chttp2/writing.c index 265448641a4..b5ca42d69c1 100644 --- a/src/core/transport/chttp2/writing.c +++ b/src/core/transport/chttp2/writing.c @@ -332,10 +332,6 @@ void grpc_chttp2_cleanup_writing( while (grpc_chttp2_list_pop_written_stream( transport_global, transport_writing, &stream_global, &stream_writing)) { - if (stream_writing->sent_trailing_metadata) { - grpc_chttp2_mark_stream_closed(exec_ctx, transport_global, stream_global, - !transport_global->is_client, 1); - } if (stream_writing->sent_initial_metadata) { grpc_chttp2_complete_closure_step( exec_ctx, &stream_global->send_initial_metadata_finished, 1); @@ -350,6 +346,10 @@ void grpc_chttp2_cleanup_writing( grpc_chttp2_complete_closure_step( exec_ctx, &stream_global->send_trailing_metadata_finished, 1); } + if (stream_writing->sent_trailing_metadata) { + grpc_chttp2_mark_stream_closed(exec_ctx, transport_global, stream_global, + !transport_global->is_client, 1); + } GRPC_CHTTP2_STREAM_UNREF(exec_ctx, stream_global, "chttp2_writing"); } gpr_slice_buffer_reset_and_unref(&transport_writing->outbuf); diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 91c1a27cff3..47268ab5fc3 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -115,11 +115,6 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_status_code status, gpr_slice *optional_message); -/** Fail any outstanding ops */ -static void fail_all_outstanding_ops( - grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global, - grpc_chttp2_stream_global *stream_global); - /** Add endpoint from this transport to pollset */ static void add_to_pollset_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, @@ -753,21 +748,6 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx, *pclosure = NULL; } -static void fail_all_outstanding_ops( - grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global, - grpc_chttp2_stream_global *stream_global) { - grpc_chttp2_complete_closure_step( - exec_ctx, &stream_global->send_initial_metadata_finished, 0); - grpc_chttp2_complete_closure_step( - exec_ctx, &stream_global->send_trailing_metadata_finished, 0); - grpc_chttp2_complete_closure_step(exec_ctx, - &stream_global->send_message_finished, 0); - grpc_chttp2_complete_closure_step( - exec_ctx, &stream_global->recv_initial_metadata_finished, 0); - grpc_chttp2_complete_closure_step( - exec_ctx, &stream_global->recv_trailing_metadata_finished, 0); -} - static int contains_non_ok_status( grpc_chttp2_transport_global *transport_global, grpc_metadata_batch *batch) { @@ -1042,9 +1022,6 @@ static void check_read_ops(grpc_exec_ctx *exec_ctx, exec_ctx, &stream_global->recv_trailing_metadata_finished, 1); } } - if (stream_global->finished_close) { - fail_all_outstanding_ops(exec_ctx, transport_global, stream_global); - } } } @@ -1146,6 +1123,12 @@ void grpc_chttp2_mark_stream_closed( } if (close_writes && !stream_global->write_closed) { stream_global->write_closed = 1; + grpc_chttp2_complete_closure_step( + exec_ctx, &stream_global->send_initial_metadata_finished, 0); + grpc_chttp2_complete_closure_step( + exec_ctx, &stream_global->send_trailing_metadata_finished, 0); + grpc_chttp2_complete_closure_step(exec_ctx, + &stream_global->send_message_finished, 0); } if (stream_global->read_closed && stream_global->write_closed) { if (stream_global->id != 0 &&