mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 10:43:56 +00:00
Merge pull request #76712 from tedyu/rr-read-lock
Use read lock for ServiceHasEndpoints
This commit is contained in:
commit
a949abc5bd
@ -122,8 +122,8 @@ func isSessionAffinity(affinity *affinityPolicy) bool {
|
|||||||
|
|
||||||
// ServiceHasEndpoints checks whether a service entry has endpoints.
|
// ServiceHasEndpoints checks whether a service entry has endpoints.
|
||||||
func (lb *LoadBalancerRR) ServiceHasEndpoints(svcPort proxy.ServicePortName) bool {
|
func (lb *LoadBalancerRR) ServiceHasEndpoints(svcPort proxy.ServicePortName) bool {
|
||||||
lb.lock.Lock()
|
lb.lock.RLock()
|
||||||
defer lb.lock.Unlock()
|
defer lb.lock.RUnlock()
|
||||||
state, exists := lb.services[svcPort]
|
state, exists := lb.services[svcPort]
|
||||||
// TODO: while nothing ever assigns nil to the map, *some* of the code using the map
|
// 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.
|
// checks for it. The code should all follow the same convention.
|
||||||
|
Loading…
Reference in New Issue
Block a user