From 149640a4c86f604c2fc56a67df52ca8b64c76e83 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Fri, 12 Jan 2018 15:48:50 -0500 Subject: Disable locking on functions in batch operations Signed-off-by: Matthew Heon Closes: #222 Approved by: rhatdan --- libpod/container_top.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'libpod/container_top.go') diff --git a/libpod/container_top.go b/libpod/container_top.go index 0eb1d0c41..3eb484acd 100644 --- a/libpod/container_top.go +++ b/libpod/container_top.go @@ -14,10 +14,12 @@ import ( // GetContainerPids reads sysfs to obtain the pids associated with the container's cgroup // and uses locking func (c *Container) GetContainerPids() ([]string, error) { - c.lock.Lock() - defer c.lock.Unlock() - if err := c.syncContainer(); err != nil { - return []string{}, errors.Wrapf(err, "error updating container %s state", c.ID()) + if !c.locked { + c.lock.Lock() + defer c.lock.Unlock() + if err := c.syncContainer(); err != nil { + return []string{}, errors.Wrapf(err, "error updating container %s state", c.ID()) + } } return c.getContainerPids() } @@ -38,10 +40,12 @@ func (c *Container) getContainerPids() ([]string, error) { // GetContainerPidInformation calls ps with the appropriate options and returns // the results as a string func (c *Container) GetContainerPidInformation(args []string) ([]string, error) { - c.lock.Lock() - defer c.lock.Unlock() - if err := c.syncContainer(); err != nil { - return []string{}, errors.Wrapf(err, "error updating container %s state", c.ID()) + if !c.locked { + c.lock.Lock() + defer c.lock.Unlock() + if err := c.syncContainer(); err != nil { + return []string{}, errors.Wrapf(err, "error updating container %s state", c.ID()) + } } pids, err := c.getContainerPids() if err != nil { -- cgit v1.2.3-54-g00ecf