Merge pull request #139 from gavwu/master

fix GetAll() potentially return an unprotected map
This commit is contained in:
qiniu-bot 2020-12-18 11:49:22 +08:00 committed by GitHub
commit ea5a6654c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -264,9 +264,13 @@ func (l *memoryStore) Get(name string) []string {
// Get returns all the registered service information
func (l *memoryStore) GetAll() map[string][]string {
res := make(map[string][]string)
l.mu.RLock()
defer l.mu.RUnlock()
return l.servicesMap
for k, v := range l.servicesMap {
res[k] = append(make([]string, 0, len(v)), v...)
}
return res
}
// Init cleanup all the registered service information