fix the goroutine leak in the stats API if the container is not running

Signed-off-by: Shijiang Wei <mountkin@gmail.com>
Upstream-commit: 1cbf5a54dae86e34d8e65508c5640b17cda0eed8
Component: engine
This commit is contained in:
Shijiang Wei
2015-06-16 22:33:49 +08:00
parent d1849214e2
commit eb72177bf2
4 changed files with 86 additions and 21 deletions

View File

@ -581,7 +581,18 @@ func (s *Server) getContainersStats(version version.Version, w http.ResponseWrit
out = ioutils.NewWriteFlusher(w)
}
return s.daemon.ContainerStats(vars["name"], stream, out)
var closeNotifier <-chan bool
if notifier, ok := w.(http.CloseNotifier); ok {
closeNotifier = notifier.CloseNotify()
}
config := &daemon.ContainerStatsConfig{
Stream: stream,
OutStream: out,
Stop: closeNotifier,
}
return s.daemon.ContainerStats(vars["name"], config)
}
func (s *Server) getContainersLogs(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {