From 71c28c7cda91aca11e3767cba4e96adc04a3f3d0 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Thu, 9 Aug 2018 17:36:10 -0400 Subject: Add batch check to container stats lock Signed-off-by: Matthew Heon Closes: #1249 Approved by: rhatdan --- libpod/stats.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'libpod') 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 } -- cgit v1.2.3-54-g00ecf