Use read lock for ServiceHasEndpoints

This commit is contained in:
Ted Yu 2019-04-17 08:10:27 -07:00 committed by Ted Yu
parent 0889c3e4e9
commit cf706531a5

View File

@ -122,8 +122,8 @@ func isSessionAffinity(affinity *affinityPolicy) bool {
// ServiceHasEndpoints checks whether a service entry has endpoints.
func (lb *LoadBalancerRR) ServiceHasEndpoints(svcPort proxy.ServicePortName) bool {
lb.lock.Lock()
defer lb.lock.Unlock()
lb.lock.RLock()
defer lb.lock.RUnlock()
state, exists := lb.services[svcPort]
// TODO: while nothing ever assigns nil to the map, *some* of the code using the map
// checks for it. The code should all follow the same convention.