From cf706531a55cd98a5be612fea539de6232a24ad6 Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Wed, 17 Apr 2019 08:10:27 -0700 Subject: [PATCH] Use read lock for ServiceHasEndpoints --- pkg/proxy/userspace/roundrobin.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/proxy/userspace/roundrobin.go b/pkg/proxy/userspace/roundrobin.go index 6bbc558eae..17ba9e2164 100644 --- a/pkg/proxy/userspace/roundrobin.go +++ b/pkg/proxy/userspace/roundrobin.go @@ -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.