mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
[filer] DATA RACE on signal_handling fixed (#3575)
This commit is contained in:
parent
a112cbe44c
commit
853880bd83
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
var signalChan chan os.Signal
|
var signalChan chan os.Signal
|
||||||
var hooks = make([]func(), 0)
|
var hooks = make([]func(), 0)
|
||||||
var hookLock sync.Mutex
|
var hookLock sync.RWMutex
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
signalChan = make(chan os.Signal, 1)
|
signalChan = make(chan os.Signal, 1)
|
||||||
|
@ -27,10 +27,12 @@ func init() {
|
||||||
// syscall.SIGQUIT,
|
// syscall.SIGQUIT,
|
||||||
)
|
)
|
||||||
go func() {
|
go func() {
|
||||||
for _ = range signalChan {
|
for range signalChan {
|
||||||
|
hookLock.RLock()
|
||||||
for _, hook := range hooks {
|
for _, hook := range hooks {
|
||||||
hook()
|
hook()
|
||||||
}
|
}
|
||||||
|
hookLock.RUnlock()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
Loading…
Reference in a new issue