From d40d3eca88b015c8f9544d6c8ebca3e666b55e05 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Fri, 3 May 2019 07:46:26 +0200 Subject: [PATCH] swap semaquire and wg.Add to avoid a deadlock --- command/build.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/command/build.go b/command/build.go index 4602f28c1..62c3a426c 100644 --- a/command/build.go +++ b/command/build.go @@ -180,13 +180,13 @@ func (c *BuildCommand) Run(args []string) int { b := builds[i] name := b.Name() ui := buildUis[name] - // Increment the waitgroup so we wait for this item to finish properly - wg.Add(1) if err := limitParallel.Acquire(buildCtx, 1); err != nil { ui.Error(fmt.Sprintf("Build '%s' failed to acquire semaphore: %s", name, err)) errors[name] = err break } + // Increment the waitgroup so we wait for this item to finish properly + wg.Add(1) // Run the build in a goroutine go func() {