[filer] DATA RACE on signal_handling fixed (#3575)

This commit is contained in:
Konstantin Lebedev 2022-09-02 18:20:19 +05:00 committed by GitHub
parent a112cbe44c
commit 853880bd83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,10 +27,12 @@ func init() {
// syscall.SIGQUIT,
)
go func() {
for _ = range signalChan {
for range signalChan {
hookLock.RLock()
for _, hook := range hooks {
hook()
}
hookLock.RUnlock()
os.Exit(0)
}
}()