[FIX] Lock and lock the map

This commit is contained in:
zhoujunhao 2018-09-27 12:19:27 +08:00
parent 8d85d6d6fe
commit b1e204f6d4

View File

@ -256,7 +256,9 @@ func (p *probeManager) WatchServiceHealthy(serviceName string) Watcher {
serviceName: serviceName,
}
if s, ok := p.watches[serviceName]; ok {
p.lock.Lock()
s[w.id] = w
p.lock.Unlock()
} else {
p.lock.Lock()
p.watches[serviceName] = map[string]*watcher{