summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-11-24 13:37:01 +0100
committerGitHub <noreply@github.com>2021-11-24 13:37:01 +0100
commit93138541f3119b81c170e5ce904a8c4e6cece842 (patch)
treed52da8d5c58559729d01b50b4fd67e0bdb92ddf7 /libpod
parent4b014a3aecf9508ed83ae489e188721e6234ccd5 (diff)
parentc7ebaeee0e642c55c4780c790f5251c8bb0fbd4c (diff)
downloadpodman-93138541f3119b81c170e5ce904a8c4e6cece842.tar.gz
podman-93138541f3119b81c170e5ce904a8c4e6cece842.tar.bz2
podman-93138541f3119b81c170e5ce904a8c4e6cece842.zip
Merge pull request #12404 from giuseppe/unlock-thread-only-on-success
libpod: leave thread locked on errors
Diffstat (limited to 'libpod')
-rw-r--r--libpod/oci_conmon_linux.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go
index 3aab6864a..8534c9fdb 100644
--- a/libpod/oci_conmon_linux.go
+++ b/libpod/oci_conmon_linux.go
@@ -847,10 +847,14 @@ func (r *ConmonOCIRuntime) CheckpointContainer(ctr *Container, options Container
err = utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, nil, r.path, args...)
// Ignore error returned from SetSocketLabel("") call,
// can't recover.
- if labelErr := label.SetSocketLabel(""); labelErr != nil {
+ if labelErr := label.SetSocketLabel(""); labelErr == nil {
+ // Unlock the thread only if the process label could be restored
+ // successfully. Otherwise leave the thread locked and the Go runtime
+ // will terminate it once it returns to the threads pool.
+ runtime.UnlockOSThread()
+ } else {
logrus.Errorf("Unable to reset socket label: %q", labelErr)
}
- runtime.UnlockOSThread()
runtimeCheckpointDuration := func() int64 {
if options.PrintStats {
@@ -1464,10 +1468,14 @@ func startCommandGivenSelinux(cmd *exec.Cmd, ctr *Container) error {
err = cmd.Start()
// Ignore error returned from SetProcessLabel("") call,
// can't recover.
- if labelErr := label.SetProcessLabel(""); labelErr != nil {
+ if labelErr := label.SetProcessLabel(""); labelErr == nil {
+ // Unlock the thread only if the process label could be restored
+ // successfully. Otherwise leave the thread locked and the Go runtime
+ // will terminate it once it returns to the threads pool.
+ runtime.UnlockOSThread()
+ } else {
logrus.Errorf("Unable to set process label: %q", labelErr)
}
- runtime.UnlockOSThread()
return err
}