Skip to content

Commit

Permalink
Merge pull request grpc#897 from menghanl/client_stream_context_comment
Browse files Browse the repository at this point in the history
Add comment for why use the user provided ctx in client side stream
  • Loading branch information
iamqizhao authored Sep 14, 2016
2 parents c5c66f1 + d1a0813 commit 71d2ea4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions transport/http2_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ func (t *http2Client) newStream(ctx context.Context, callHdr *CallHdr) *Stream {
s.windowHandler = func(n int) {
t.updateWindow(s, uint32(n))
}
// The client side stream context should have exactly the same life cycle with the user provided context.
// That means, s.ctx should be read-only. And s.ctx is done iff ctx is done.
// So we use the original context here instead of creating a copy.
s.ctx = ctx
s.dec = &recvBufferReader{
ctx: s.ctx,
Expand Down

0 comments on commit 71d2ea4

Please sign in to comment.