21227: Fix unbuffered channels used for signal.Notify.
authorTom Clegg <tom@curii.com>
Fri, 1 Dec 2023 20:47:06 +0000 (15:47 -0500)
committerTom Clegg <tom@curii.com>
Fri, 1 Dec 2023 20:47:06 +0000 (15:47 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

lib/boot/supervisor.go
services/keep-balance/server.go

index 28be8f3a1409725fb8b14da8fc2c264c3d6d1606..e25fb8cdbad524b0d70b76a4aa9d130c3dbcfb18 100644 (file)
@@ -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)
index b20144e3af9cae063f50f3ac5246e6f038ccbd2f..480791ffa2637da8f282fb28507dbbcb046bcfbf 100644 (file)
@@ -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")