Add a separate lock for pid.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2019-02-01 02:08:49 -08:00
parent 9777d76890
commit 952d58297d
3 changed files with 26 additions and 8 deletions

View File

@@ -23,6 +23,7 @@ import (
"io"
"os"
"strings"
"sync"
"time"
"github.com/containerd/containerd/errdefs"
@@ -31,6 +32,18 @@ import (
"golang.org/x/sys/unix"
)
// safePid is a thread safe wrapper for pid.
type safePid struct {
sync.Mutex
pid int
}
func (s *safePid) get() int {
s.Lock()
defer s.Unlock()
return s.pid
}
// TODO(mlaventure): move to runc package?
func getLastRuntimeError(r *runc.Runc) (string, error) {
if r.Log == "" {