From c179b0ffc7e2a2a75f890b86a73f0180e65548c8 Mon Sep 17 00:00:00 2001 From: Zhang Wei Date: Thu, 20 Oct 2016 17:57:37 +0800 Subject: [PATCH] Some refactor and cleanup Signed-off-by: Zhang Wei --- libcontainer/state_linux.go | 9 ++------- utils_linux.go | 3 +-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/libcontainer/state_linux.go b/libcontainer/state_linux.go index 266282404..d8ea40092 100644 --- a/libcontainer/state_linux.go +++ b/libcontainer/state_linux.go @@ -83,10 +83,7 @@ func (b *stoppedState) status() Status { func (b *stoppedState) transition(s containerState) error { switch s.(type) { - case *runningState: - b.c.state = s - return nil - case *restoredState: + case *runningState, *restoredState: b.c.state = s return nil case *stoppedState: @@ -212,9 +209,7 @@ func (r *restoredState) status() Status { func (r *restoredState) transition(s containerState) error { switch s.(type) { - case *stoppedState: - return nil - case *runningState: + case *stoppedState, *runningState: return nil } return newStateTransitionError(r, s) diff --git a/utils_linux.go b/utils_linux.go index 2e3b192ad..c97500b41 100644 --- a/utils_linux.go +++ b/utils_linux.go @@ -295,7 +295,6 @@ func startContainer(context *cli.Context, spec *specs.Spec, create bool) (int, e if err != nil { return -1, err } - detach := context.Bool("detach") // Support on-demand socket activation by passing file descriptors into the container init process. listenFDs := []*os.File{} if os.Getenv("LISTEN_FDS") != "" { @@ -307,7 +306,7 @@ func startContainer(context *cli.Context, spec *specs.Spec, create bool) (int, e container: container, listenFDs: listenFDs, console: context.String("console"), - detach: detach, + detach: context.Bool("detach"), pidFile: context.String("pid-file"), create: create, }