Avoid ServeApi race condition

If job "acceptconnections" is called before "serveapi" the API Accept()
method will hang forever waiting for activation.  This is due to the fact
that when "acceptconnections" ran the activation channel was nil.

Signed-off-by: Darren Shepherd <darren@rancher.com>
(cherry picked from commit 8f6a14452d)

Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <princess@docker.com> (github: jfrazelle)

Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <hugs@docker.com> (github: jfrazelle)
This commit is contained in:
Darren Shepherd
2015-03-31 16:43:16 -07:00
committed by Jessica Frazelle
parent 7d7bec86c9
commit 72e14a1566
+1 -2
View File
@@ -38,7 +38,7 @@ import (
)
var (
activationLock chan struct{}
activationLock chan struct{} = make(chan struct{})
)
type HttpServer struct {
@@ -1578,7 +1578,6 @@ func ServeApi(job *engine.Job) engine.Status {
protoAddrs = job.Args
chErrors = make(chan error, len(protoAddrs))
)
activationLock = make(chan struct{})
for _, protoAddr := range protoAddrs {
protoAddrParts := strings.SplitN(protoAddr, "://", 2)