Close tcp connection when client stops '/events' request.

Signed-off-by: Dong Chen <dongluo.chen@docker.com>
This commit is contained in:
Dong Chen 2015-11-24 16:18:18 -08:00
parent 1b2afce425
commit 59a1f2427b
1 changed files with 8 additions and 0 deletions

View File

@ -46,8 +46,16 @@ func (eh *eventsHandler) Wait(remoteAddr string, until int64) {
timer = time.NewTimer(dur)
}
// subscribe to http client close event
w := eh.ws[remoteAddr]
var closeNotify <-chan bool
if closeNotifier, ok := w.(http.CloseNotifier); ok {
closeNotify = closeNotifier.CloseNotify()
}
select {
case <-eh.cs[remoteAddr]:
case <-closeNotify:
case <-timer.C: // `--until` timeout
close(eh.cs[remoteAddr])
}