Skip to content

Commit

Permalink
Merge pull request #1316 from coryb/goroutine-leak
Browse files Browse the repository at this point in the history
ensure context is cancelled to prevent goroutine leaks from grpc.newClientStream
  • Loading branch information
tonistiigi authored Jan 17, 2020
2 parents aa4311b + 463fc8d commit 8a26782
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion util/flightcontrol/flightcontrol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8a26782

Please sign in to comment.