Skip to content

Commit 2590357

Browse files
bduffanyadityamaru
authored andcommitted
Fix goroutine leak in startVMM
Signed-off-by: Brandon Duffany <brandon@buildbuddy.io>
1 parent 1f80072 commit 2590357

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

machine.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,16 @@ func (m *Machine) startVMM(ctx context.Context) error {
608608
return err
609609
}
610610

611-
// This goroutine is used to kill the process by context cancelletion,
611+
// This goroutine is used to kill the process by context cancellation,
612612
// but doesn't tell anyone about that.
613613
go func() {
614-
<-ctx.Done()
614+
select {
615+
case <-ctx.Done():
616+
break
617+
case <-m.exitCh:
618+
// VMM exited on its own; no need to stop it.
619+
return
620+
}
615621
err := m.stopVMM()
616622
if err != nil {
617623
m.logger.WithError(err).Errorf("failed to stop vm %q", m.Cfg.VMID)

0 commit comments

Comments
 (0)