From 5f47f9f5ccafea3a8423f786b76a190df8a8067c Mon Sep 17 00:00:00 2001 From: Menghan Li Date: Mon, 12 Sep 2016 13:23:05 -0700 Subject: [PATCH] Use user context instead of creating new context for client side stream --- transport/http2_client.go | 3 +-- transport/transport.go | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/transport/http2_client.go b/transport/http2_client.go index e9cf6bec..6f9dd0f5 100644 --- a/transport/http2_client.go +++ b/transport/http2_client.go @@ -252,8 +252,7 @@ func (t *http2Client) newStream(ctx context.Context, callHdr *CallHdr) *Stream { s.windowHandler = func(n int) { t.updateWindow(s, uint32(n)) } - // Make a stream be able to cancel the pending operations by itself. - s.ctx, s.cancel = context.WithCancel(ctx) + s.ctx = ctx s.dec = &recvBufferReader{ ctx: s.ctx, goAway: s.goAway, diff --git a/transport/transport.go b/transport/transport.go index f4d8dafa..e2f691ef 100644 --- a/transport/transport.go +++ b/transport/transport.go @@ -169,7 +169,8 @@ type Stream struct { // nil for client side Stream. st ServerTransport // ctx is the associated context of the stream. - ctx context.Context + ctx context.Context + // cancel is always nil for client side Stream. cancel context.CancelFunc // done is closed when the final status arrives. done chan struct{}