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:
Josh Poimboeuf 2013-11-11 21:58:40 -06:00
Родитель 457375ea37
Коммит fc2f5758cf
1 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

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