New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server: respond correctly to client headers with END_STREAM flag set #3803
Changes from 1 commit
ddfcffe
16540ed
8dee198
823ab91
b3675e1
c923ada
cb544ea
cd4c0fa
44f802d
7b5f2ab
8f6a20f
9ed72b9
7d2dbd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4647,21 +4647,21 @@ func (s) TestClientInitialHeaderEndStream(t *testing.T) { | |
|
||
func testClientInitialHeaderEndStream(t *testing.T, e env) { | ||
// To ensure RST_STREAM is sent for illegal data write and not normal stream close. | ||
frameCheckingDone := make(chan bool, 1) | ||
frameCheckingDone := make(chan struct{}) | ||
// To ensure goroutine for test does not end before RPC handler performs error checking. | ||
handlerDone := make(chan bool, 1) | ||
handlerDone := make(chan struct{}) | ||
te := newTest(t, e) | ||
ts := &funcServer{streamingInputCall: func(stream testpb.TestService_StreamingInputCallServer) error { | ||
defer func() { | ||
handlerDone <- true | ||
close(handlerDone) | ||
}() | ||
// Block on serverTester receiving RST_STREAM. This ensures server has closed stream before stream.Recv(). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make sure to wrap comments at 80 columns for readability. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrapped comments |
||
<-frameCheckingDone | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment here to explain why we need to block until the server has sent the RST_STREAM. And in the test below, too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a comment. |
||
_, err := stream.Recv() | ||
data, err := stream.Recv() | ||
if err == nil { | ||
t.Error("unexpected data received in func server method") | ||
return nil | ||
t.Errorf("unexpected data received in func server method: '%v'", data) | ||
} else if status.Code(err) != codes.Canceled { | ||
t.Errorf("expected status canceled error, instead received '%v'", err) | ||
t.Errorf("expected canceled error, instead received '%v'", err) | ||
} | ||
return nil | ||
}} | ||
|
@@ -4674,7 +4674,7 @@ func testClientInitialHeaderEndStream(t *testing.T, e env) { | |
st.wantAnyFrame() | ||
st.wantAnyFrame() | ||
st.wantRSTStream(http2.ErrCodeStreamClosed) | ||
dfawley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
frameCheckingDone <- true | ||
close(frameCheckingDone) | ||
<-handlerDone | ||
}) | ||
} | ||
|
@@ -4690,14 +4690,15 @@ func (s) TestClientSendDataAfterCloseSend(t *testing.T) { | |
|
||
func testClientSendDataAfterCloseSend(t *testing.T, e env) { | ||
// To ensure RST_STREAM is sent for illegal data write prior to execution of RPC handler. | ||
frameCheckingDone := make(chan bool, 1) | ||
frameCheckingDone := make(chan struct{}) | ||
// To ensure goroutine for test does not end before RPC handler performs error checking. | ||
handlerDone := make(chan bool, 1) | ||
handlerDone := make(chan struct{}) | ||
te := newTest(t, e) | ||
ts := &funcServer{streamingInputCall: func(stream testpb.TestService_StreamingInputCallServer) error { | ||
defer func() { | ||
handlerDone <- true | ||
close(handlerDone) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made this change. |
||
}() | ||
// Block on serverTester receiving RST_STREAM. This ensures server has closed stream before stream.Recv(). | ||
<-frameCheckingDone | ||
for { | ||
_, err := stream.Recv() | ||
|
@@ -4706,7 +4707,7 @@ func testClientSendDataAfterCloseSend(t *testing.T, e env) { | |
} | ||
if err != nil { | ||
if status.Code(err) != codes.Canceled { | ||
t.Errorf("expected status canceled error, instead received '%v'", err) | ||
t.Errorf("expected canceled error, instead received '%v'", err) | ||
} | ||
break | ||
} | ||
|
@@ -4728,7 +4729,7 @@ func testClientSendDataAfterCloseSend(t *testing.T, e env) { | |
st.wantAnyFrame() | ||
st.wantAnyFrame() | ||
st.wantRSTStream(http2.ErrCodeStreamClosed) | ||
frameCheckingDone <- true | ||
close(frameCheckingDone) | ||
<-handlerDone | ||
}) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just
defer close(handlerDone)
now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made this change.