mirror of https://github.com/docker/docs.git
Close TCP connections at disconnect.
Signed-off-by: Dong Chen <dongluo.chen@docker.com>
This commit is contained in:
parent
984aab2999
commit
87a03b9157
|
|
@ -218,10 +218,20 @@ func (e *Engine) Disconnect() {
|
||||||
// close the chan
|
// close the chan
|
||||||
close(e.stopCh)
|
close(e.stopCh)
|
||||||
e.client.StopAllMonitorEvents()
|
e.client.StopAllMonitorEvents()
|
||||||
|
// close idle connections
|
||||||
|
if dc, ok := e.client.(*dockerclient.DockerClient); ok {
|
||||||
|
closeIdleConnections(dc.HTTPClient)
|
||||||
|
}
|
||||||
e.client = nopclient.NewNopClient()
|
e.client = nopclient.NewNopClient()
|
||||||
e.emitEvent("engine_disconnect")
|
e.emitEvent("engine_disconnect")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func closeIdleConnections(client *http.Client) {
|
||||||
|
if tr, ok := client.Transport.(*http.Transport); ok {
|
||||||
|
tr.CloseIdleConnections()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// isConnected returns true if the engine is connected to a remote docker API
|
// isConnected returns true if the engine is connected to a remote docker API
|
||||||
func (e *Engine) isConnected() bool {
|
func (e *Engine) isConnected() bool {
|
||||||
_, ok := e.client.(*nopclient.NopClient)
|
_, ok := e.client.(*nopclient.NopClient)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue