progress: make sure all channels have written before returning

Possible write on closed channel on cancellation before.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2020-10-16 22:49:29 -07:00
parent 232af9aa0d
commit 40fad4bbb5
4 changed files with 13 additions and 5 deletions

View File

@@ -658,7 +658,9 @@ func Build(ctx context.Context, drivers []DriverInfo, opt map[string]Options, do
eg.Go(func() error {
defer wg.Done()
rr, err := c.Solve(ctx, nil, so, progress.NewChannel(pw))
ch, done := progress.NewChannel(pw)
defer func() { <-done }()
rr, err := c.Solve(ctx, nil, so, ch)
if err != nil {
return err
}