Skip to content

Commit

Permalink
net/http: fix timer leak in Transport when using ResponseHeaderTimeout
Browse files Browse the repository at this point in the history
Fixes #9104

Change-Id: Ide5ac70215d73278e6910f5b9c7687ad7734c0be
Reviewed-on: https://go-review.googlesource.com/1530
Reviewed-by: David Symonds <dsymonds@golang.org>
  • Loading branch information
bradfitz committed Dec 13, 2014
1 parent d160d1b commit 0e4ee0c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/net/http/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,9 @@ WaitResponse:
break WaitResponse
}
if d := pc.t.ResponseHeaderTimeout; d > 0 {
respHeaderTimer = time.After(d)
timer := time.NewTimer(d)
defer timer.Stop() // prevent leaks
respHeaderTimer = timer.C
}
case <-pconnDeadCh:
// The persist connection is dead. This shouldn't
Expand Down

0 comments on commit 0e4ee0c

Please sign in to comment.