Merge pull request #13712 from LK4D4/fix_leak_events

Support CloseNotifier for events
This commit is contained in:
Arnaud Porterie 2015-06-03 13:43:39 -07:00
commit ad56d797d3

View file

@ -461,6 +461,12 @@ func (s *Server) getEvents(version version.Version, w http.ResponseWriter, r *ht
return err
}
}
var closeNotify <-chan bool
if closeNotifier, ok := w.(http.CloseNotifier); ok {
closeNotify = closeNotifier.CloseNotify()
}
for {
select {
case ev := <-l:
@ -473,6 +479,9 @@ func (s *Server) getEvents(version version.Version, w http.ResponseWriter, r *ht
}
case <-timer.C:
return nil
case <-closeNotify:
logrus.Debug("Client disconnected, stop sending events")
return nil
}
}
}