mirror of
https://github.com/moby/moby.git
synced 2025-07-30 18:23:29 +03:00
Fix goroutine leak on logs -f with no output
Also noticed potential hang when only stdout or stderr are used with follow=1 Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
@ -597,6 +597,11 @@ func (s *Server) getContainersLogs(version version.Version, w http.ResponseWrite
|
||||
since = time.Unix(s, 0)
|
||||
}
|
||||
|
||||
var closeNotifier <-chan bool
|
||||
if notifier, ok := w.(http.CloseNotifier); ok {
|
||||
closeNotifier = notifier.CloseNotify()
|
||||
}
|
||||
|
||||
logsConfig := &daemon.ContainerLogsConfig{
|
||||
Follow: boolValue(r, "follow"),
|
||||
Timestamps: boolValue(r, "timestamps"),
|
||||
@ -605,6 +610,7 @@ func (s *Server) getContainersLogs(version version.Version, w http.ResponseWrite
|
||||
UseStdout: stdout,
|
||||
UseStderr: stderr,
|
||||
OutStream: ioutils.NewWriteFlusher(w),
|
||||
Stop: closeNotifier,
|
||||
}
|
||||
|
||||
if err := s.daemon.ContainerLogs(vars["name"], logsConfig); err != nil {
|
||||
|
Reference in New Issue
Block a user