Commit 676c8ec8 authored by Eric's avatar Eric

[Update] optimize memory usage

parent 3ed7a99f
...@@ -172,18 +172,14 @@ var Conf = &Config{ ...@@ -172,18 +172,14 @@ var Conf = &Config{
ZipTmpPath: "/tmp", ZipTmpPath: "/tmp",
} }
func SetConf(conf *Config) { func SetConf(conf Config) {
lock.Lock() lock.Lock()
defer lock.Unlock() defer lock.Unlock()
Conf = conf Conf = &conf
} }
func GetConf() *Config { func GetConf() Config {
lock.RLock() lock.RLock()
defer lock.RUnlock() defer lock.RUnlock()
var conf Config return *Conf
if confBytes, err := json.Marshal(Conf); err == nil {
_ = json.Unmarshal(confBytes, &conf)
}
return &conf
} }
...@@ -87,7 +87,7 @@ func MustLoadServerConfigOnce() { ...@@ -87,7 +87,7 @@ func MustLoadServerConfigOnce() {
func LoadConfigFromServer() (err error) { func LoadConfigFromServer() (err error) {
conf := config.GetConf() conf := config.GetConf()
_, err = authClient.Get(TerminalConfigURL, conf) _, err = authClient.Get(TerminalConfigURL, &conf)
if err != nil { if err != nil {
return err return err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment