From ca9a6378779e1bbee61b43eaa5e17a80c001da27 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 15 Dec 2015 18:16:28 -0800 Subject: [PATCH] Fix double read at end of stream bug --- src/core/surface/call.c | 2 ++ test/cpp/end2end/end2end_test.cc | 1 + 2 files changed, 3 insertions(+) diff --git a/src/core/surface/call.c b/src/core/surface/call.c index a162d99193d..d18319a97da 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -1060,6 +1060,7 @@ static void receiving_stream_ready(grpc_exec_ctx *exec_ctx, void *bctlp, if (call->receiving_stream == NULL) { *call->receiving_buffer = NULL; + call->receiving_message = 0; if (gpr_unref(&bctl->steps_to_complete)) { post_batch_completion(exec_ctx, bctl); } @@ -1070,6 +1071,7 @@ static void receiving_stream_ready(grpc_exec_ctx *exec_ctx, void *bctlp, grpc_byte_stream_destroy(call->receiving_stream); call->receiving_stream = NULL; *call->receiving_buffer = NULL; + call->receiving_message = 0; if (gpr_unref(&bctl->steps_to_complete)) { post_batch_completion(exec_ctx, bctl); } diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index dd02c4ac16c..bbeac7a30b3 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -543,6 +543,7 @@ TEST_P(End2endTest, BidiStream) { stream->WritesDone(); EXPECT_FALSE(stream->Read(&response)); + EXPECT_FALSE(stream->Read(&response)); Status s = stream->Finish(); EXPECT_TRUE(s.ok());