Skip to content

Commit

Permalink
fix cond unlock (alibaba#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
2456868764 authored Jun 25, 2023
1 parent 39cab9d commit 5e2d624
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions registry/nacos/address/address_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func (p *NacosAddressProvider) GetNacosAddress(oldAddress string) <-chan string
go func() {
var addr string
p.cond.L.Lock()
defer p.cond.L.Unlock()
log.Debugf("get nacos address, p.nacosAddr, oldAddress", p.nacosAddr, oldAddress)
for p.nacosAddr == oldAddress || p.nacosAddr == "" {
if p.isStop.Load() {
Expand All @@ -123,7 +124,6 @@ func (p *NacosAddressProvider) GetNacosAddress(oldAddress string) <-chan string
p.cond.Wait()
}
addr = p.nacosAddr
p.cond.L.Unlock()
addressChan <- addr
}()
return addressChan
Expand Down Expand Up @@ -160,6 +160,7 @@ func (p *NacosAddressProvider) addressDiscovery() {
}
needUpdate := true
p.cond.L.Lock()
defer p.cond.L.Unlock()
for _, address := range addrVec {
ip := net.ParseIP(address)
if ip == nil {
Expand All @@ -181,5 +182,4 @@ func (p *NacosAddressProvider) addressDiscovery() {
p.nacosBackupAddr = append(p.nacosBackupAddr[:i], p.nacosBackupAddr[i+1:]...)
}
}
p.cond.L.Unlock()
}

0 comments on commit 5e2d624

Please sign in to comment.