1
0
Fork 0
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:
Alexandr Morozov 2014-08-14 15:51:31 +04:00
parent 1480168e9f
commit 93d6adf8a1
No known key found for this signature in database
GPG key ID: 59BF89FA47378873

View file

@ -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) {