Jelajahi Sumber

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>
Darren Shepherd 10 tahun lalu
induk
melakukan
8f6a14452d
1 mengubah file dengan 1 tambahan dan 2 penghapusan
  1. 1 2
      api/server/server.go

+ 1 - 2
api/server/server.go

@@ -39,7 +39,7 @@ import (
 )
 )
 
 
 var (
 var (
-	activationLock chan struct{}
+	activationLock chan struct{} = make(chan struct{})
 )
 )
 
 
 type HttpServer struct {
 type HttpServer struct {
@@ -1593,7 +1593,6 @@ func ServeApi(job *engine.Job) error {
 		protoAddrs = job.Args
 		protoAddrs = job.Args
 		chErrors   = make(chan error, len(protoAddrs))
 		chErrors   = make(chan error, len(protoAddrs))
 	)
 	)
-	activationLock = make(chan struct{})
 
 
 	for _, protoAddr := range protoAddrs {
 	for _, protoAddr := range protoAddrs {
 		protoAddrParts := strings.SplitN(protoAddr, "://", 2)
 		protoAddrParts := strings.SplitN(protoAddr, "://", 2)