mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix race in stats cli and native driver
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
parent
628c396555
commit
77280a87b7
2 changed files with 4 additions and 0 deletions
|
@ -37,7 +37,9 @@ func (s *containerStats) Collect(cli *DockerCli, streamStats bool) {
|
|||
}
|
||||
stream, _, err := cli.call("GET", "/containers/"+s.Name+"/stats?"+v.Encode(), nil, nil)
|
||||
if err != nil {
|
||||
s.mu.Lock()
|
||||
s.err = err
|
||||
s.mu.Unlock()
|
||||
return
|
||||
}
|
||||
defer stream.Close()
|
||||
|
|
|
@ -335,7 +335,9 @@ func (d *driver) Clean(id string) error {
|
|||
}
|
||||
|
||||
func (d *driver) Stats(id string) (*execdriver.ResourceStats, error) {
|
||||
d.Lock()
|
||||
c := d.activeContainers[id]
|
||||
d.Unlock()
|
||||
if c == nil {
|
||||
return nil, execdriver.ErrNotRunning
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue