diff --git a/proxy/proxy.go b/proxy/proxy.go index 3a410ea8..e90c7f57 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -359,11 +359,11 @@ func (proxy *Proxy) waitForStart(r *http.Request) error { } // If some other operation is waiting for a container to start, join in the wait -func (proxy *Proxy) waitForStartByIdent(ident string) { - var ch chan struct{} +func (proxy *Proxy) waitForStartByIdent(ident string) error { + var ch chan error proxy.Lock() for _, wait := range proxy.waiters { - if ident == wait.ident { + if ident == wait.ident && !wait.done { ch = wait.ch break } @@ -371,8 +371,9 @@ func (proxy *Proxy) waitForStartByIdent(ident string) { proxy.Unlock() if ch != nil { Log.Debugf("Wait for start of container %s", ident) - <-ch + return <-ch } + return nil } func (proxy *Proxy) ContainerDied(ident string) { @@ -519,7 +520,9 @@ func (proxy *Proxy) updateContainerNetworkSettings(container jsonObject) error { return err } - proxy.waitForStartByIdent(containerID) + if err := proxy.waitForStartByIdent(containerID); err != nil { + return err + } mac, ips, nets, err := weaveContainerIPs(containerID) if err != nil || len(ips) == 0 { return err