Merge pull request #897 from menghanl/client_stream_context_comment

Add comment for why use the user provided ctx in client side stream
This commit is contained in:
Qi Zhao
2016-09-14 14:33:45 -07:00
committed by GitHub

View File

@ -252,6 +252,9 @@ func (t *http2Client) newStream(ctx context.Context, callHdr *CallHdr) *Stream {
s.windowHandler = func(n int) { s.windowHandler = func(n int) {
t.updateWindow(s, uint32(n)) 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.ctx = ctx
s.dec = &recvBufferReader{ s.dec = &recvBufferReader{
ctx: s.ctx, ctx: s.ctx,