Skip to content

Commit

Permalink
Fix leak of first instance gun closing
Browse files Browse the repository at this point in the history
If gun has slow Close method, main function could exit before closing complete.
  • Loading branch information
rapthead authored and Grigorii Lipin committed Apr 12, 2022
1 parent e9de11f commit 8852933
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,10 @@ func (p *instancePool) startInstances(
}
started++
go func() {
defer firstInstance.Close()
runRes <- instanceRunResult{0, firstInstance.Run(runCtx)}
runRes <- instanceRunResult{0, func() error {
defer firstInstance.Close()
return firstInstance.Run(runCtx)
}()}
}()

for ; waiter.Wait(); started++ {
Expand Down

0 comments on commit 8852933

Please sign in to comment.