Skip to content

Commit 8dba8bd

Browse files
committed
Don't close m.exitCh just after context cancelletion
The context is used to let the SDK kill its underlying Firecracker process. Closing the channel has to be happening after the actual termination of the process. Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent 2fd80c0 commit 8dba8bd

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

machine.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,14 +516,19 @@ func (m *Machine) startVMM(ctx context.Context) error {
516516

517517
return err
518518
}
519+
520+
// This goroutine is used to kill the process by context cancelletion,
521+
// but doesn't tell anyone about that.
519522
go func() {
520-
select {
521-
case <-ctx.Done():
522-
m.fatalErr = ctx.Err()
523-
case err := <-errCh:
524-
m.fatalErr = err
525-
}
523+
<-ctx.Done()
524+
m.stopVMM()
525+
}()
526526

527+
// This goroutine is used to tell clients that the process is stopped
528+
// (gracefully or not).
529+
go func() {
530+
m.fatalErr = <-errCh
531+
m.logger.Debugf("closing the exitCh %v", m.fatalErr)
527532
close(m.exitCh)
528533
}()
529534

0 commit comments

Comments
 (0)