mirror of https://github.com/docker/docs.git
Merge pull request #1447 from dongluochen/eventsConnection
Close tcp connection when client stops '/events' request.
This commit is contained in:
commit
088ad94a61
|
|
@ -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])
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue