From 2ddb9375f6a0136852af1cbdb68b1edd68ea8bcc Mon Sep 17 00:00:00 2001 From: mike kabischev Date: Fri, 10 Feb 2017 16:17:57 +0300 Subject: [PATCH] fix leaking http connections --- controller/endpoint/http.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/controller/endpoint/http.go b/controller/endpoint/http.go index 34c3cd53..e2d01f49 100644 --- a/controller/endpoint/http.go +++ b/controller/endpoint/http.go @@ -33,15 +33,7 @@ func newHTTPEndpointConn(ep Endpoint) *HTTPEndpointConn { } func (conn *HTTPEndpointConn) Expired() bool { - conn.mu.Lock() - defer conn.mu.Unlock() - if !conn.ex { - if time.Now().Sub(conn.t) > httpExpiresAfter { - conn.ex = true - conn.client = nil - } - } - return conn.ex + return false } func (conn *HTTPEndpointConn) Send(msg string) error { @@ -55,6 +47,7 @@ func (conn *HTTPEndpointConn) Send(msg string) error { conn.client = &http.Client{ Transport: &http.Transport{ MaxIdleConnsPerHost: httpMaxIdleConnections, + IdleConnTimeout: httpExpiresAfter, }, Timeout: httpRequestTimeout, }