aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/repro/repro.go21
-rw-r--r--pkg/repro/repro_test.go1
2 files changed, 14 insertions, 8 deletions
diff --git a/pkg/repro/repro.go b/pkg/repro/repro.go
index b030d38bd..daebeed18 100644
--- a/pkg/repro/repro.go
+++ b/pkg/repro/repro.go
@@ -77,7 +77,14 @@ func Run(crashLog []byte, cfg *mgrconfig.Config, features *host.Features, report
if err != nil {
return nil, nil, err
}
- go ctx.createInstances(cfg, vmPool, vmIndexes)
+ var wg sync.WaitGroup
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ ctx.createInstances(cfg, vmPool, vmIndexes)
+ }()
+ // Wait until all VMs are really released.
+ defer wg.Wait()
return ctx.run()
}
@@ -135,12 +142,8 @@ func prepareCtx(crashLog []byte, cfg *mgrconfig.Config, features *host.Features,
}
func (ctx *context) run() (*Result, *Stats, error) {
- defer func() {
- close(ctx.bootRequests)
- for inst := range ctx.instances {
- inst.execProg.Close()
- }
- }()
+ // Indicate that we no longer need VMs.
+ defer close(ctx.bootRequests)
res, err := ctx.repro()
if err != nil {
@@ -739,7 +742,11 @@ func (ctx *context) createInstances(cfg *mgrconfig.Config, vmPool *vm.Pool, vmIn
}()
}
wg.Wait()
+ // Clean up.
close(ctx.instances)
+ for inst := range ctx.instances {
+ inst.execProg.Close()
+ }
}
type Simplify func(opts *csource.Options) bool
diff --git a/pkg/repro/repro_test.go b/pkg/repro/repro_test.go
index 51c99eb75..ebe3809e0 100644
--- a/pkg/repro/repro_test.go
+++ b/pkg/repro/repro_test.go
@@ -119,7 +119,6 @@ func generateTestInstances(ctx *context, count int, execInterface execInterface)
}
}()
wg.Wait()
- close(ctx.instances)
}
type testExecInterface struct {