From 3e65a597ea81688774098a921246006ec3e933f6 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Fri, 1 Dec 2023 15:47:06 -0500 Subject: [PATCH] 21227: Fix unbuffered channels used for signal.Notify. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- lib/boot/supervisor.go | 2 +- services/keep-balance/server.go | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/boot/supervisor.go b/lib/boot/supervisor.go index 28be8f3a14..e25fb8cdba 100644 --- a/lib/boot/supervisor.go +++ b/lib/boot/supervisor.go @@ -111,7 +111,7 @@ func (super *Supervisor) Start(ctx context.Context) { super.ctx, super.cancel = context.WithCancel(ctx) super.done = make(chan struct{}) - sigch := make(chan os.Signal) + sigch := make(chan os.Signal, 1) signal.Notify(sigch, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP) go func() { defer signal.Stop(sigch) diff --git a/services/keep-balance/server.go b/services/keep-balance/server.go index b20144e3af..480791ffa2 100644 --- a/services/keep-balance/server.go +++ b/services/keep-balance/server.go @@ -98,9 +98,7 @@ func (srv *Server) runForever(ctx context.Context) error { ticker := time.NewTicker(time.Duration(srv.Cluster.Collections.BalancePeriod)) - // The unbuffered channel here means we only hear SIGUSR1 if - // it arrives while we're waiting in select{}. - sigUSR1 := make(chan os.Signal) + sigUSR1 := make(chan os.Signal, 1) signal.Notify(sigUSR1, syscall.SIGUSR1) logger.Info("acquiring service lock") -- 2.30.2