fix: concurrent iteration map need lock.
This commit is contained in:
parent
4d3d475c27
commit
829c7af1bc
4
hosts.go
4
hosts.go
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue