fix: concurrent iteration map need lock.

This commit is contained in:
kenshinx 2017-05-18 17:29:56 +08:00
parent 4d3d475c27
commit 829c7af1bc
1 changed files with 2 additions and 2 deletions

View File

@ -101,10 +101,10 @@ type RedisHosts struct {
} }
func (r *RedisHosts) Get(domain string) ([]string, bool) { func (r *RedisHosts) Get(domain string) ([]string, bool) {
domain = strings.ToLower(domain)
r.mu.RLock() r.mu.RLock()
defer r.mu.RUnlock()
domain = strings.ToLower(domain)
ip, ok := r.hosts[domain] ip, ok := r.hosts[domain]
r.mu.RUnlock()
if ok { if ok {
return strings.Split(ip, ","), true return strings.Split(ip, ","), true
} }