From 5207b2fcbacade72e0b18dccb0477ef6a254e4b2 Mon Sep 17 00:00:00 2001 From: gaojiasheng Date: Sat, 16 May 2020 00:14:42 +0800 Subject: [PATCH] delete useless lock --- src/modules/collector/config/config.go | 8 -------- src/modules/index/config/config.go | 7 ------- src/modules/monapi/config/yaml.go | 6 ------ src/modules/tsdb/config/config.go | 8 -------- 4 files changed, 29 deletions(-) diff --git a/src/modules/collector/config/config.go b/src/modules/collector/config/config.go index 23dee8c4..0be9c003 100644 --- a/src/modules/collector/config/config.go +++ b/src/modules/collector/config/config.go @@ -3,8 +3,6 @@ package config import ( "bytes" "fmt" - "sync" - "github.com/didi/nightingale/src/modules/collector/log/worker" "github.com/didi/nightingale/src/modules/collector/stra" "github.com/didi/nightingale/src/modules/collector/sys" @@ -24,15 +22,12 @@ type ConfYaml struct { var ( Config *ConfYaml - lock = new(sync.RWMutex) Endpoint string Cwd string ) // Get configuration file func Get() *ConfYaml { - lock.RLock() - defer lock.RUnlock() return Config } @@ -42,9 +37,6 @@ func Parse(conf string) error { return fmt.Errorf("cannot read yml[%s]: %v", conf, err) } - lock.Lock() - defer lock.Unlock() - viper.SetConfigType("yaml") err = viper.ReadConfig(bytes.NewBuffer(bs)) if err != nil { diff --git a/src/modules/index/config/config.go b/src/modules/index/config/config.go index 45b50456..4963ef8d 100644 --- a/src/modules/index/config/config.go +++ b/src/modules/index/config/config.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "strconv" - "sync" "github.com/didi/nightingale/src/modules/index/cache" "github.com/didi/nightingale/src/toolkits/address" @@ -35,12 +34,9 @@ type RPCSection struct { var ( Config *ConfYaml - lock = new(sync.RWMutex) ) func GetCfgYml() *ConfYaml { - lock.RLock() - defer lock.RUnlock() return Config } @@ -50,9 +46,6 @@ func Parse(conf string) error { return fmt.Errorf("cannot read yml[%s]: %v", conf, err) } - lock.Lock() - defer lock.Unlock() - viper.SetConfigType("yaml") err = viper.ReadConfig(bytes.NewBuffer(bs)) if err != nil { diff --git a/src/modules/monapi/config/yaml.go b/src/modules/monapi/config/yaml.go index 1745c1f8..26f0fbc5 100644 --- a/src/modules/monapi/config/yaml.go +++ b/src/modules/monapi/config/yaml.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "sort" - "sync" "github.com/spf13/viper" "github.com/toolkits/pkg/file" @@ -87,13 +86,10 @@ type ldapAttributes struct { var ( yaml *Config - lock = new(sync.RWMutex) ) // Get configuration file func Get() *Config { - lock.RLock() - defer lock.RUnlock() return yaml } @@ -153,9 +149,7 @@ func Parse(ymlfile string) error { c.Queue.EventQueues = append(c.Queue.EventQueues, prefix+prios[i]) } - lock.Lock() yaml = &c - lock.Unlock() return nil } diff --git a/src/modules/tsdb/config/config.go b/src/modules/tsdb/config/config.go index d3c4cacb..5267b890 100644 --- a/src/modules/tsdb/config/config.go +++ b/src/modules/tsdb/config/config.go @@ -3,8 +3,6 @@ package config import ( "bytes" "fmt" - "sync" - "github.com/didi/nightingale/src/modules/tsdb/backend/rpc" "github.com/didi/nightingale/src/modules/tsdb/cache" "github.com/didi/nightingale/src/modules/tsdb/index" @@ -45,12 +43,9 @@ type RpcSection struct { var ( Config *ConfYaml - lock = new(sync.RWMutex) ) func GetCfgYml() *ConfYaml { - lock.RLock() - defer lock.RUnlock() return Config } @@ -60,9 +55,6 @@ func Parse(conf string) error { return fmt.Errorf("cannot read yml[%s]: %v", conf, err) } - lock.Lock() - defer lock.Unlock() - viper.SetConfigType("yaml") err = viper.ReadConfig(bytes.NewBuffer(bs)) if err != nil { -- GitLab