From 920250e41481d5c0d1ca99830e56d6ca6a554778 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Thu, 29 Oct 2015 12:05:06 +0000 Subject: [PATCH] Close idle http connections when we stop a Http Publisher. --- xfer/http_publisher.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xfer/http_publisher.go b/xfer/http_publisher.go index 6accfd7ae..c3da1a18b 100644 --- a/xfer/http_publisher.go +++ b/xfer/http_publisher.go @@ -119,7 +119,12 @@ func (p HTTPPublisher) Publish(r io.Reader) error { } // Stop implements Publisher -func (p HTTPPublisher) Stop() {} +func (p *HTTPPublisher) Stop() { + // We replace the HTTPPublishers pretty regularly, so we need to ensure the + // underlying connections get closed, or we end up with lots of idle + // goroutines on the server (see #604) + p.client.Transport.(*http.Transport).CloseIdleConnections() +} // AuthorizationHeader returns a value suitable for an HTTP Authorization // header, based on the passed token string.