diff --git a/weed/util/grace/signal_handling.go b/weed/util/grace/signal_handling.go index fc7afcad9..24d2b184f 100644 --- a/weed/util/grace/signal_handling.go +++ b/weed/util/grace/signal_handling.go @@ -12,7 +12,7 @@ import ( var signalChan chan os.Signal var hooks = make([]func(), 0) -var hookLock sync.Mutex +var hookLock sync.RWMutex func init() { signalChan = make(chan os.Signal, 1) @@ -27,7 +27,9 @@ func init() { // syscall.SIGQUIT, ) go func() { - for _ = range signalChan { + hookLock.RLock() + defer hookLock.RUnlock() + for range signalChan { for _, hook := range hooks { hook() }