Skip to content

Commit a949abc

Browse files
authored
Merge pull request kubernetes#76712 from tedyu/rr-read-lock
Use read lock for ServiceHasEndpoints
2 parents a5a70b4 + cf70653 commit a949abc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/proxy/userspace/roundrobin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ func isSessionAffinity(affinity *affinityPolicy) bool {
122122

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

0 commit comments

Comments
 (0)