1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Make sure all containers (even previously stopped) get a correct wait lock

This commit is contained in:
Guillaume J. Charmes 2013-04-09 17:40:02 -07:00
parent 40ebe78bb1
commit 9f83b9df22

View file

@ -134,6 +134,9 @@ func (runtime *Runtime) Register(container *Container) error {
return err
}
// init the wait lock
container.waitLock = make(chan struct{})
// FIXME: if the container is supposed to be running but is not, auto restart it?
// if so, then we need to restart monitor and init a new lock
// If the container is supposed to be running, make sure of it
@ -150,6 +153,14 @@ func (runtime *Runtime) Register(container *Container) error {
}
}
}
// If the container is not running or just has been flagged not running
// then close the wait lock chan (will be reset upon start)
if !container.State.Running {
close(container.waitLock)
}
// Even if not running, we init the lock (prevents races in start/stop/kill)
container.State.initLock()
container.runtime = runtime