fix leaking http connections

This commit is contained in:
mike kabischev 2017-02-10 16:17:57 +03:00
parent 237d4b2284
commit 2ddb9375f6
1 changed files with 2 additions and 9 deletions

View File

@ -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,
}