Skip to content

Commit

Permalink
remove unused WaitGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
xiantang committed Jun 24, 2024
1 parent 360714a commit 849e029
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions runner/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,7 @@ func (e *Engine) runPostCmd() error {
}

func (e *Engine) runBin() error {
killFunc := func(cmd *exec.Cmd, stdout io.ReadCloser, stderr io.ReadCloser, killCh chan struct{}, processExit chan struct{}, wg *sync.WaitGroup) {
defer wg.Done()
killFunc := func(cmd *exec.Cmd, stdout io.ReadCloser, stderr io.ReadCloser, killCh chan struct{}, processExit chan struct{}) {
select {
// listen to binStopCh
// cleanup() will close binStopCh when engine stop
Expand Down Expand Up @@ -519,13 +518,11 @@ func (e *Engine) runBin() error {

e.runnerLog("running...")
go func() {
wg := sync.WaitGroup{}

defer func() {
select {
case <-e.exitCh:
e.mainDebug("exit in runBin")
wg.Wait()
default:
}
}()
Expand All @@ -546,11 +543,10 @@ func (e *Engine) runBin() error {
e.proxy.Reload()
}

wg.Add(1)
e.withLock(func() {
close(e.binStopCh)
e.binStopCh = make(chan bool)
go killFunc(cmd, stdout, stderr, killCh, processExit, &wg)
go killFunc(cmd, stdout, stderr, killCh, processExit)
})

go func() {
Expand Down

0 comments on commit 849e029

Please sign in to comment.