]> Cypherpunks repositories - gostls13.git/commit
net/http: remove idle transport connections from Transport when server closes
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 26 Apr 2016 22:43:04 +0000 (15:43 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 27 Apr 2016 03:30:59 +0000 (03:30 +0000)
commit2e30218223a7bf2b560fbaf79bac8d80ea4ece1c
treed807ee391ca819da0dbf04b183fa350d4418f387
parent87bca88c703c1f14fe8473dc2f07dc521cf2b989
net/http: remove idle transport connections from Transport when server closes

Previously the Transport would cache idle connections from the
Transport for later reuse, but if a peer server disconnected
(e.g. idle timeout), we would not proactively remove the *persistConn
from the Transport's idle list, leading to a waste of memory
(potentially forever).

Instead, when the persistConn's readLoop terminates, remote it from
the idle list, if present.

This also adds the beginning of accounting for the total number of
idle connections, which will be needed for Transport.MaxIdleConns
later.

Updates #15461

Change-Id: Iab091f180f8dd1ee0d78f34b9705d68743b5557b
Reviewed-on: https://go-review.googlesource.com/22492
Reviewed-by: Andrew Gerrand <adg@golang.org>
src/net/http/main_test.go
src/net/http/transport.go
src/net/http/transport_test.go