Skip to content

Commit 71d2ea4

Browse files
authored
Merge pull request grpc#897 from menghanl/client_stream_context_comment
Add comment for why use the user provided ctx in client side stream
2 parents c5c66f1 + d1a0813 commit 71d2ea4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

transport/http2_client.go

+3
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ func (t *http2Client) newStream(ctx context.Context, callHdr *CallHdr) *Stream {
252252
s.windowHandler = func(n int) {
253253
t.updateWindow(s, uint32(n))
254254
}
255+
// The client side stream context should have exactly the same life cycle with the user provided context.
256+
// That means, s.ctx should be read-only. And s.ctx is done iff ctx is done.
257+
// So we use the original context here instead of creating a copy.
255258
s.ctx = ctx
256259
s.dec = &recvBufferReader{
257260
ctx: s.ctx,

0 commit comments

Comments
 (0)