mirror of https://github.com/tidwall/tile38.git
fix leaking http connections
This commit is contained in:
parent
237d4b2284
commit
2ddb9375f6
|
@ -33,15 +33,7 @@ func newHTTPEndpointConn(ep Endpoint) *HTTPEndpointConn {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *HTTPEndpointConn) Expired() bool {
|
func (conn *HTTPEndpointConn) Expired() bool {
|
||||||
conn.mu.Lock()
|
return false
|
||||||
defer conn.mu.Unlock()
|
|
||||||
if !conn.ex {
|
|
||||||
if time.Now().Sub(conn.t) > httpExpiresAfter {
|
|
||||||
conn.ex = true
|
|
||||||
conn.client = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return conn.ex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *HTTPEndpointConn) Send(msg string) error {
|
func (conn *HTTPEndpointConn) Send(msg string) error {
|
||||||
|
@ -55,6 +47,7 @@ func (conn *HTTPEndpointConn) Send(msg string) error {
|
||||||
conn.client = &http.Client{
|
conn.client = &http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
MaxIdleConnsPerHost: httpMaxIdleConnections,
|
MaxIdleConnsPerHost: httpMaxIdleConnections,
|
||||||
|
IdleConnTimeout: httpExpiresAfter,
|
||||||
},
|
},
|
||||||
Timeout: httpRequestTimeout,
|
Timeout: httpRequestTimeout,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue