Merge pull request #13712 from LK4D4/fix_leak_events
Support CloseNotifier for events
This commit is contained in:
commit
ad56d797d3
1 changed files with 9 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue