mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-14 04:56:38 +08:00
fix: protect shared rules across delivery and recovery (#560)
This commit is contained in:
@@ -23,10 +23,20 @@ func init() {
|
||||
}
|
||||
|
||||
var (
|
||||
global = &Config{}
|
||||
globalMux sync.RWMutex
|
||||
global = &Config{}
|
||||
globalMux sync.RWMutex
|
||||
mutationMux sync.Mutex
|
||||
)
|
||||
|
||||
// LockMutation serializes complete runtime/config transactions across panel
|
||||
// commands, management API requests, startup and reload. It is separate from
|
||||
// globalMux so callers may safely use Global, Set and OnUpdate while holding it.
|
||||
// Lock before reading/parsing the config and hold through persistence/rollback.
|
||||
func LockMutation() func() {
|
||||
mutationMux.Lock()
|
||||
return mutationMux.Unlock
|
||||
}
|
||||
|
||||
func Global() *Config {
|
||||
globalMux.RLock()
|
||||
defer globalMux.RUnlock()
|
||||
|
||||
Reference in New Issue
Block a user