From 7240f83f9f17bf72fbc4d068143003eba000cc75 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 3 Dec 2021 12:29:39 +0000 Subject: fix misuse of unbuffered channel for OS signal handling --- Makefile | 3 ++- cmd/dserver/main.go | 2 +- internal/io/signal/signal.go | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index a3b299c..680cef6 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,8 @@ vet: echo ${GO} vet $$dir; \ ${GO} vet $$dir; \ done - grep -R TODO: . + sh -c 'grep -R NEXT: .' + sh -c 'grep -R TODO: .' lint: ${GO} get golang.org/x/lint/golint find . -type d | while read dir; do \ diff --git a/cmd/dserver/main.go b/cmd/dserver/main.go index fff41f0..14188e1 100644 --- a/cmd/dserver/main.go +++ b/cmd/dserver/main.go @@ -55,7 +55,7 @@ func main() { ctx, cancel = context.WithTimeout(ctx, time.Duration(shutdownAfter)*time.Second) } - sigCh := make(chan os.Signal) + sigCh := make(chan os.Signal, 10) signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM) go func() { diff --git a/internal/io/signal/signal.go b/internal/io/signal/signal.go index 584b59c..c01e82a 100644 --- a/internal/io/signal/signal.go +++ b/internal/io/signal/signal.go @@ -12,9 +12,9 @@ import ( // InterruptCh returns a channel for "please print stats" signalling. func InterruptCh(ctx context.Context) <-chan string { - sigIntCh := make(chan os.Signal) + sigIntCh := make(chan os.Signal, 10) gosignal.Notify(sigIntCh, os.Interrupt) - sigOtherCh := make(chan os.Signal) + sigOtherCh := make(chan os.Signal, 10) gosignal.Notify(sigOtherCh, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGQUIT) statsCh := make(chan string) -- cgit v1.2.3