summaryrefslogtreecommitdiff
path: root/libpod/util.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2018-11-20 11:06:20 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2018-11-27 12:34:11 +0100
commit070ce0c85570b79a3612ad1fdf15b5c1287b00b6 (patch)
treedc1771eefd634a89a1452704c245232bf97ec978 /libpod/util.go
parent049defa98426c50dab781c0493d54aca00a7fbb8 (diff)
downloadpodman-070ce0c85570b79a3612ad1fdf15b5c1287b00b6.tar.gz
podman-070ce0c85570b79a3612ad1fdf15b5c1287b00b6.tar.bz2
podman-070ce0c85570b79a3612ad1fdf15b5c1287b00b6.zip
exec: don't wait for pidfile when the runtime exited
don't wait for the timeout to expire if the runtime process exited. I've noticed podman to hang on exit and keeping the container lock taken when the OCI runtime already exited. Additionally, it reduces the waiting time as we won't hit the 25 milliseconds waiting time in the worst case. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod/util.go')
-rw-r--r--libpod/util.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/libpod/util.go b/libpod/util.go
index 7007b29cd..25e78bd01 100644
--- a/libpod/util.go
+++ b/libpod/util.go
@@ -90,7 +90,7 @@ func MountExists(specMounts []spec.Mount, dest string) bool {
}
// WaitForFile waits until a file has been created or the given timeout has occurred
-func WaitForFile(path string, timeout time.Duration) error {
+func WaitForFile(path string, chWait chan error, timeout time.Duration) (bool, error) {
done := make(chan struct{})
chControl := make(chan struct{})
go func() {
@@ -110,11 +110,13 @@ func WaitForFile(path string, timeout time.Duration) error {
}()
select {
+ case e := <-chWait:
+ return true, e
case <-done:
- return nil
+ return false, nil
case <-time.After(timeout):
close(chControl)
- return errors.Wrapf(ErrInternal, "timed out waiting for file %s", path)
+ return false, errors.Wrapf(ErrInternal, "timed out waiting for file %s", path)
}
}