mirror of
https://github.com/docker/docs.git
synced 2026-03-28 23:08:49 +07:00
fix container restart race condition
Finish container cleanup before setting the state to stopped. Otherwise, for an application that exits quickly, a call to Restart can allow Start to be called again before cleanup is done, resulting in overritten data in the Container struct.
This commit is contained in:
@@ -1287,9 +1287,6 @@ func (container *Container) monitor() {
|
||||
exitCode = container.cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
|
||||
}
|
||||
|
||||
// Report status back
|
||||
container.State.setStopped(exitCode)
|
||||
|
||||
if container.runtime != nil && container.runtime.srv != nil {
|
||||
container.runtime.srv.LogEvent("die", container.ID, container.runtime.repositories.ImageName(container.Image))
|
||||
}
|
||||
@@ -1302,6 +1299,9 @@ func (container *Container) monitor() {
|
||||
container.stdin, container.stdinPipe = io.Pipe()
|
||||
}
|
||||
|
||||
// Report status back
|
||||
container.State.setStopped(exitCode)
|
||||
|
||||
// Release the lock
|
||||
close(container.waitLock)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user