From fa325ea2a584870297485b7ada7ee3d3b7fc7e2a Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 4 Oct 2019 04:16:35 +0000 Subject: [PATCH] [release-branch.go1.13] net/http: update bundled http2 for memory leak fix This re-runs go generate with x/net checked out at CL 198617 on the release-branch.go1.13 branch for: [release-branch.go1.13] http2: fix memory leak in random write scheduler Fixes golang/go#34636 Updates golang/go#33812 Change-Id: Ibce630c6c7ffe43ff760d2ad40b44731c07ba870 Reviewed-on: https://go-review.googlesource.com/c/go/+/198897 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Bryan C. Mills --- src/net/http/h2_bundle.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go index 53cc5bd1b8..e9a55f388a 100644 --- a/src/net/http/h2_bundle.go +++ b/src/net/http/h2_bundle.go @@ -10148,7 +10148,8 @@ type http2randomWriteScheduler struct { zero http2writeQueue // sq contains the stream-specific queues, keyed by stream ID. - // When a stream is idle or closed, it's deleted from the map. + // When a stream is idle, closed, or emptied, it's deleted + // from the map. sq map[uint32]*http2writeQueue // pool of empty queues for reuse. @@ -10192,8 +10193,12 @@ func (ws *http2randomWriteScheduler) Pop() (http2FrameWriteRequest, bool) { return ws.zero.shift(), true } // Iterate over all non-idle streams until finding one that can be consumed. - for _, q := range ws.sq { + for streamID, q := range ws.sq { if wr, ok := q.consume(math.MaxInt32); ok { + if q.empty() { + delete(ws.sq, streamID) + ws.queuePool.put(q) + } return wr, true } } -- 2.48.1