summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-08-09 17:36:10 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-10 15:00:33 +0000
commit71c28c7cda91aca11e3767cba4e96adc04a3f3d0 (patch)
tree0adb667755a684cf2e4182d345ac96b341b3b28c /libpod
parentc27b7cdc933f7102a3d093fa303f3ddb48209838 (diff)
downloadpodman-71c28c7cda91aca11e3767cba4e96adc04a3f3d0.tar.gz
podman-71c28c7cda91aca11e3767cba4e96adc04a3f3d0.tar.bz2
podman-71c28c7cda91aca11e3767cba4e96adc04a3f3d0.zip
Add batch check to container stats lock
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #1249 Approved by: rhatdan
Diffstat (limited to 'libpod')
-rw-r--r--libpod/stats.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/libpod/stats.go b/libpod/stats.go
index 262c1ac00..7830919ba 100644
--- a/libpod/stats.go
+++ b/libpod/stats.go
@@ -16,11 +16,15 @@ func (c *Container) GetContainerStats(previousStats *ContainerStats) (*Container
stats := new(ContainerStats)
stats.ContainerID = c.ID()
stats.Name = c.Name()
- c.lock.Lock()
- defer c.lock.Unlock()
- if err := c.syncContainer(); err != nil {
- return stats, err
+
+ if !c.batched {
+ c.lock.Lock()
+ defer c.lock.Unlock()
+ if err := c.syncContainer(); err != nil {
+ return stats, err
+ }
}
+
if c.state.State != ContainerStateRunning {
return stats, nil
}