Manager: allow requesting shutdown multiple times

It's fine to request a shutdown multiple times. This fixes a hard crash
due to a panic.
This commit is contained in:
Sybren A. Stüvel 2022-07-14 18:22:13 +02:00
parent 73f98f93a0
commit b35af5de9f

@ -83,6 +83,11 @@ func (f *Flamenco) WaitForShutdown(ctx context.Context) bool {
// requestShutdown closes the 'done' channel, signalling to callers of
// WaitForShutdown() that a shutdown is requested.
func (f *Flamenco) requestShutdown() {
defer func() {
// Recover the panic that happens when the channel is closed multiple times.
// Requesting a shutdown should be possible multiple times without panicing.
recover()
}()
close(f.done)
}