diff --git a/cluster/swarm/cluster.go b/cluster/swarm/cluster.go index 32e0ed7946..47a40c0431 100644 --- a/cluster/swarm/cluster.go +++ b/cluster/swarm/cluster.go @@ -332,12 +332,10 @@ func (c *Cluster) Load(imageReader io.Reader, callback func(what, status string) c.RLock() pipeWriters := []*io.PipeWriter{} - pipeReaders := []*io.PipeReader{} for _, n := range c.engines { wg.Add(1) pipeReader, pipeWriter := io.Pipe() - pipeReaders = append(pipeReaders, pipeReader) pipeWriters = append(pipeWriters, pipeWriter) go func(reader *io.PipeReader, nn *cluster.Engine) { @@ -353,6 +351,7 @@ func (c *Cluster) Load(imageReader io.Reader, callback func(what, status string) } }(pipeReader, n) } + c.RUnlock() // create multi-writer listWriter := []io.Writer{} @@ -372,8 +371,6 @@ func (c *Cluster) Load(imageReader io.Reader, callback func(what, status string) pipeW.Close() } - c.RUnlock() - wg.Wait() }