Skip to content

Commit c4198ad

Browse files
author
Mrunal Patel
authored
Merge pull request #1134 from WeiZhang555/tiny-refactor
Some refactor and cleanup
2 parents fa5e0cd + c179b0f commit c4198ad

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

libcontainer/state_linux.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ func (b *stoppedState) status() Status {
8383

8484
func (b *stoppedState) transition(s containerState) error {
8585
switch s.(type) {
86-
case *runningState:
87-
b.c.state = s
88-
return nil
89-
case *restoredState:
86+
case *runningState, *restoredState:
9087
b.c.state = s
9188
return nil
9289
case *stoppedState:
@@ -212,9 +209,7 @@ func (r *restoredState) status() Status {
212209

213210
func (r *restoredState) transition(s containerState) error {
214211
switch s.(type) {
215-
case *stoppedState:
216-
return nil
217-
case *runningState:
212+
case *stoppedState, *runningState:
218213
return nil
219214
}
220215
return newStateTransitionError(r, s)

utils_linux.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ func startContainer(context *cli.Context, spec *specs.Spec, create bool) (int, e
295295
if err != nil {
296296
return -1, err
297297
}
298-
detach := context.Bool("detach")
299298
// Support on-demand socket activation by passing file descriptors into the container init process.
300299
listenFDs := []*os.File{}
301300
if os.Getenv("LISTEN_FDS") != "" {
@@ -307,7 +306,7 @@ func startContainer(context *cli.Context, spec *specs.Spec, create bool) (int, e
307306
container: container,
308307
listenFDs: listenFDs,
309308
console: context.String("console"),
310-
detach: detach,
309+
detach: context.Bool("detach"),
311310
pidFile: context.String("pid-file"),
312311
create: create,
313312
}

0 commit comments

Comments
 (0)