From 546a87fd5b1d60dada413309c70dbb253536b0da Mon Sep 17 00:00:00 2001 From: jholdstock Date: Mon, 18 Sep 2023 13:51:06 +0100 Subject: [PATCH] vspd: Remove shutdownRequestChannel. The removal of the requestShutdown function in a previous commit means that the shutdownRequestChannel is no longer needed, so this commit removes it. --- cmd/vspd/main.go | 2 +- cmd/vspd/signal.go | 20 ++++---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/cmd/vspd/main.go b/cmd/vspd/main.go index 638fa2e..b22894c 100644 --- a/cmd/vspd/main.go +++ b/cmd/vspd/main.go @@ -107,7 +107,7 @@ func run() int { var shutdownWg sync.WaitGroup // Create a context that is canceled when a shutdown request is received - // through an interrupt signal. + // through an interrupt signal such as SIGINT (Ctrl+C). ctx := shutdownListener(log) // Start the webapi server. diff --git a/cmd/vspd/signal.go b/cmd/vspd/signal.go index 0809929..42ff1a2 100644 --- a/cmd/vspd/signal.go +++ b/cmd/vspd/signal.go @@ -13,10 +13,6 @@ import ( "github.com/decred/slog" ) -// shutdownRequestChannel is used to initiate shutdown from one of the -// subsystems using the same code paths as when an interrupt signal is received. -var shutdownRequestChannel = make(chan struct{}) - // interruptSignals defines the signals that are handled to do a clean shutdown. // Conditional compilation is used to also include SIGTERM and SIGHUP on Unix. var interruptSignals = []os.Signal{os.Interrupt} @@ -31,24 +27,16 @@ func shutdownListener(log slog.Logger) context.Context { signal.Notify(interruptChannel, interruptSignals...) // Listen for the initial shutdown signal. - select { - case sig := <-interruptChannel: - log.Infof("Received signal (%s). Shutting down...", sig) - case <-shutdownRequestChannel: - log.Info("Shutdown requested. Shutting down...") - } + sig := <-interruptChannel + log.Infof("Received signal (%s). Shutting down...", sig) cancel() // Listen for any more shutdown request and display a message so the // user knows the shutdown is in progress and the process is not hung. for { - select { - case sig := <-interruptChannel: - log.Infof("Received signal (%s). Already shutting down...", sig) - case <-shutdownRequestChannel: - log.Info("Shutdown requested. Already shutting down...") - } + sig := <-interruptChannel + log.Infof("Received signal (%s). Already shutting down...", sig) } }() return ctx