delete useless lock

This commit is contained in:
gaojiasheng 2020-05-16 00:14:42 +08:00
parent 806a392d0f
commit 5207b2fcba
4 changed files with 0 additions and 29 deletions

View File

@ -3,8 +3,6 @@ package config
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"sync"
"github.com/didi/nightingale/src/modules/collector/log/worker" "github.com/didi/nightingale/src/modules/collector/log/worker"
"github.com/didi/nightingale/src/modules/collector/stra" "github.com/didi/nightingale/src/modules/collector/stra"
"github.com/didi/nightingale/src/modules/collector/sys" "github.com/didi/nightingale/src/modules/collector/sys"
@ -24,15 +22,12 @@ type ConfYaml struct {
var ( var (
Config *ConfYaml Config *ConfYaml
lock = new(sync.RWMutex)
Endpoint string Endpoint string
Cwd string Cwd string
) )
// Get configuration file // Get configuration file
func Get() *ConfYaml { func Get() *ConfYaml {
lock.RLock()
defer lock.RUnlock()
return Config return Config
} }
@ -42,9 +37,6 @@ func Parse(conf string) error {
return fmt.Errorf("cannot read yml[%s]: %v", conf, err) return fmt.Errorf("cannot read yml[%s]: %v", conf, err)
} }
lock.Lock()
defer lock.Unlock()
viper.SetConfigType("yaml") viper.SetConfigType("yaml")
err = viper.ReadConfig(bytes.NewBuffer(bs)) err = viper.ReadConfig(bytes.NewBuffer(bs))
if err != nil { if err != nil {

View File

@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"strconv" "strconv"
"sync"
"github.com/didi/nightingale/src/modules/index/cache" "github.com/didi/nightingale/src/modules/index/cache"
"github.com/didi/nightingale/src/toolkits/address" "github.com/didi/nightingale/src/toolkits/address"
@ -35,12 +34,9 @@ type RPCSection struct {
var ( var (
Config *ConfYaml Config *ConfYaml
lock = new(sync.RWMutex)
) )
func GetCfgYml() *ConfYaml { func GetCfgYml() *ConfYaml {
lock.RLock()
defer lock.RUnlock()
return Config return Config
} }
@ -50,9 +46,6 @@ func Parse(conf string) error {
return fmt.Errorf("cannot read yml[%s]: %v", conf, err) return fmt.Errorf("cannot read yml[%s]: %v", conf, err)
} }
lock.Lock()
defer lock.Unlock()
viper.SetConfigType("yaml") viper.SetConfigType("yaml")
err = viper.ReadConfig(bytes.NewBuffer(bs)) err = viper.ReadConfig(bytes.NewBuffer(bs))
if err != nil { if err != nil {

View File

@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"sort" "sort"
"sync"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/toolkits/pkg/file" "github.com/toolkits/pkg/file"
@ -87,13 +86,10 @@ type ldapAttributes struct {
var ( var (
yaml *Config yaml *Config
lock = new(sync.RWMutex)
) )
// Get configuration file // Get configuration file
func Get() *Config { func Get() *Config {
lock.RLock()
defer lock.RUnlock()
return yaml return yaml
} }
@ -153,9 +149,7 @@ func Parse(ymlfile string) error {
c.Queue.EventQueues = append(c.Queue.EventQueues, prefix+prios[i]) c.Queue.EventQueues = append(c.Queue.EventQueues, prefix+prios[i])
} }
lock.Lock()
yaml = &c yaml = &c
lock.Unlock()
return nil return nil
} }

View File

@ -3,8 +3,6 @@ package config
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"sync"
"github.com/didi/nightingale/src/modules/tsdb/backend/rpc" "github.com/didi/nightingale/src/modules/tsdb/backend/rpc"
"github.com/didi/nightingale/src/modules/tsdb/cache" "github.com/didi/nightingale/src/modules/tsdb/cache"
"github.com/didi/nightingale/src/modules/tsdb/index" "github.com/didi/nightingale/src/modules/tsdb/index"
@ -45,12 +43,9 @@ type RpcSection struct {
var ( var (
Config *ConfYaml Config *ConfYaml
lock = new(sync.RWMutex)
) )
func GetCfgYml() *ConfYaml { func GetCfgYml() *ConfYaml {
lock.RLock()
defer lock.RUnlock()
return Config return Config
} }
@ -60,9 +55,6 @@ func Parse(conf string) error {
return fmt.Errorf("cannot read yml[%s]: %v", conf, err) return fmt.Errorf("cannot read yml[%s]: %v", conf, err)
} }
lock.Lock()
defer lock.Unlock()
viper.SetConfigType("yaml") viper.SetConfigType("yaml")
err = viper.ReadConfig(bytes.NewBuffer(bs)) err = viper.ReadConfig(bytes.NewBuffer(bs))
if err != nil { if err != nil {