Merge pull request #139 from gavwu/master
fix GetAll() potentially return an unprotected map
This commit is contained in:
commit
ea5a6654c3
@ -264,9 +264,13 @@ func (l *memoryStore) Get(name string) []string {
|
|||||||
|
|
||||||
// Get returns all the registered service information
|
// Get returns all the registered service information
|
||||||
func (l *memoryStore) GetAll() map[string][]string {
|
func (l *memoryStore) GetAll() map[string][]string {
|
||||||
|
res := make(map[string][]string)
|
||||||
l.mu.RLock()
|
l.mu.RLock()
|
||||||
defer l.mu.RUnlock()
|
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
|
// Init cleanup all the registered service information
|
||||||
|
Loading…
Reference in New Issue
Block a user