From 463fc8d1b8f41864baa9928b11c02fff36810e42 Mon Sep 17 00:00:00 2001 From: Cory Bennett Date: Tue, 7 Jan 2020 14:35:17 -0800 Subject: [PATCH] ensure context is cancelled to prevent goroutine leaks from grpc.newClientStream Signed-off-by: Cory Bennett --- util/flightcontrol/flightcontrol.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/flightcontrol/flightcontrol.go b/util/flightcontrol/flightcontrol.go index 120be2f12555..f06d4e895499 100644 --- a/util/flightcontrol/flightcontrol.go +++ b/util/flightcontrol/flightcontrol.go @@ -116,7 +116,9 @@ func newCall(fn func(ctx context.Context) (interface{}, error)) *call { func (c *call) run() { defer c.closeProgressWriter() - v, err := c.fn(c.ctx) + ctx, cancel := context.WithCancel(c.ctx) + defer cancel() + v, err := c.fn(ctx) c.mu.Lock() c.result = v c.err = err