1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/container
Paweł Gronowski 85b9568d0e state/Wait: Fix race when reading exit status
Before this change there was a race condition between State.Wait reading
the exit code from State and the State being changed instantly after the
change which ended the State.Wait.

Now, each State.Wait has its own channel which is used to transmit the
desired StateStatus at the time the state transitions to the awaited
one. Wait no longer reads the status by itself so there is no race.

The issue caused the `docker run --restart=always ...' to sometimes exit
with 0 exit code, because the process was already restarted by the time
State.Wait got the chance to read the exit code.

Test run
--------
Before:
```
$ go test -count 1 -run TestCorrectStateWaitResultAfterRestart .
--- FAIL: TestCorrectStateWaitResultAfterRestart (0.00s)
    state_test.go:198: expected exit code 10, got 0
FAIL
FAIL    github.com/docker/docker/container      0.011s
FAIL

```

After:
```
$ go test -count 1 -run TestCorrectStateWaitResultAfterRestart .
ok      github.com/docker/docker/container      0.011s
```

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2022-07-29 16:49:56 +02:00
..
stream refactor: move from io/ioutil to io and os package 2021-08-27 14:56:57 +08:00
archive.go
container.go state/Wait: Fix race when reading exit status 2022-07-29 16:49:56 +02:00
container_unit_test.go container: StopSignal(): return syscall.Signal 2022-05-05 00:53:53 +02:00
container_unix.go refactor: move from io/ioutil to io and os package 2021-08-27 14:56:57 +08:00
container_windows.go pkg/signal: remove DefaultStopSignal const 2021-08-11 10:31:29 +02:00
env.go Use strings.Index instead of strings.Split 2020-04-24 11:10:13 -07:00
env_test.go Use strings.Index instead of strings.Split 2020-04-24 11:10:13 -07:00
health.go
history.go
memory_store.go
memory_store_test.go
monitor.go
mounts_unix.go Update to Go 1.17.0, and gofmt with Go 1.17 2021-08-24 23:33:27 +02:00
mounts_windows.go
state.go state/Wait: Fix race when reading exit status 2022-07-29 16:49:56 +02:00
state_test.go state/Wait: Fix race when reading exit status 2022-07-29 16:49:56 +02:00
store.go
view.go
view_test.go refactor: move from io/ioutil to io and os package 2021-08-27 14:56:57 +08:00