From 72e14a156691bcc2c3a2c01d16175eb9bfd1cef2 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 30 Mar 2015 17:39:43 -0700 Subject: [PATCH] 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 (cherry picked from commit 8f6a14452dfd88aedc8ac9577a98c38a555baadc) Docker-DCO-1.1-Signed-off-by: Jessie Frazelle (github: jfrazelle) Docker-DCO-1.1-Signed-off-by: Jessie Frazelle (github: jfrazelle) --- api/server/server.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/server/server.go b/api/server/server.go index 453b4c69a..cfbb7f253 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -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)