1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #13444 from runcom/fix-race-stats

Fix race in stats cli and native driver
This commit is contained in:
Alexander Morozov 2015-05-26 15:34:50 -07:00
commit 0d445685b8
2 changed files with 8 additions and 0 deletions

View file

@ -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()

View file

@ -259,7 +259,9 @@ func (d *driver) Kill(c *execdriver.Command, sig int) error {
}
func (d *driver) Pause(c *execdriver.Command) error {
d.Lock()
active := d.activeContainers[c.ID]
d.Unlock()
if active == nil {
return fmt.Errorf("active container for %s does not exist", c.ID)
}
@ -267,7 +269,9 @@ func (d *driver) Pause(c *execdriver.Command) error {
}
func (d *driver) Unpause(c *execdriver.Command) error {
d.Lock()
active := d.activeContainers[c.ID]
d.Unlock()
if active == nil {
return fmt.Errorf("active container for %s does not exist", c.ID)
}
@ -335,7 +339,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
}