Fix bug that shouldn't exist

This commit is contained in:
Daniel 2019-03-08 23:17:56 +01:00
parent a8e7d0ecc7
commit 2fd7e3fbc7

View file

@ -1,6 +1,7 @@
package modules
import (
"errors"
"fmt"
"github.com/tevino/abool"
@ -53,6 +54,13 @@ func checkStopStatus() (readyToStop []*Module, done bool) {
// Shutdown stops all modules in the correct order.
func Shutdown() error {
if shutdownSignalClosed.SetToIf(false, true) {
close(shutdownSignal)
} else {
// shutdown was already issued
return errors.New("shutdown already initiated")
}
if startComplete.IsSet() {
log.Warning("modules: starting shutdown...")
modulesLock.Lock()
@ -61,10 +69,6 @@ func Shutdown() error {
log.Warning("modules: aborting, shutting down...")
}
if shutdownSignalClosed.SetToIf(false, true) {
close(shutdownSignal)
}
reports := make(chan error, 10)
for {
readyToStop, done := checkStopStatus()