mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix race between container cleanup and inspect/ps
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
This commit is contained in:
parent
1480168e9f
commit
93d6adf8a1
1 changed files with 13 additions and 1 deletions
|
@ -103,8 +103,17 @@ func (m *containerMonitor) Start() error {
|
|||
exitStatus int
|
||||
)
|
||||
|
||||
// this variable indicates that we under container.Lock
|
||||
underLock := true
|
||||
|
||||
// ensure that when the monitor finally exits we release the networking and unmount the rootfs
|
||||
defer m.Close()
|
||||
defer func() {
|
||||
if !underLock {
|
||||
m.container.Lock()
|
||||
defer m.container.Unlock()
|
||||
}
|
||||
m.Close()
|
||||
}()
|
||||
|
||||
// reset the restart count
|
||||
m.container.RestartCount = -1
|
||||
|
@ -136,6 +145,9 @@ func (m *containerMonitor) Start() error {
|
|||
log.Errorf("Error running container: %s", err)
|
||||
}
|
||||
|
||||
// here container.Lock is already lost
|
||||
underLock = false
|
||||
|
||||
m.resetMonitor(err == nil && exitStatus == 0)
|
||||
|
||||
if m.shouldRestart(exitStatus) {
|
||||
|
|
Loading…
Add table
Reference in a new issue