summaryrefslogtreecommitdiff
path: root/libpod/container_top.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-01-12 15:48:50 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-14 12:27:33 +0000
commit149640a4c86f604c2fc56a67df52ca8b64c76e83 (patch)
treee0fec55026021ac6cfde5bd9a40b82156246c80a /libpod/container_top.go
parent5599b64e727ccfa0e2ce992689846c59bb51e4ad (diff)
downloadpodman-149640a4c86f604c2fc56a67df52ca8b64c76e83.tar.gz
podman-149640a4c86f604c2fc56a67df52ca8b64c76e83.tar.bz2
podman-149640a4c86f604c2fc56a67df52ca8b64c76e83.zip
Disable locking on functions in batch operations
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #222 Approved by: rhatdan
Diffstat (limited to 'libpod/container_top.go')
-rw-r--r--libpod/container_top.go20
1 files changed, 12 insertions, 8 deletions
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 {