Skip to content

Commit

Permalink
Merge pull request #12404 from giuseppe/unlock-thread-only-on-success
Browse files Browse the repository at this point in the history
libpod: leave thread locked on errors
  • Loading branch information
openshift-merge-robot authored Nov 24, 2021
2 parents 4b014a3 + c7ebaee commit 9313854
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions libpod/oci_conmon_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 9313854

Please sign in to comment.