Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
ea59d1f4
Commit
ea59d1f4
authored
Jul 12, 2024
by
Brad Davidson
Committed by
Brad Davidson
Jul 15, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix reentrant rlock in loadbalancer.dialContext
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
30468326
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
servers.go
pkg/agent/loadbalancer/servers.go
+5
-3
No files found.
pkg/agent/loadbalancer/servers.go
View file @
ea59d1f4
...
@@ -111,10 +111,12 @@ func (lb *LoadBalancer) setServers(serverAddresses []string) bool {
...
@@ -111,10 +111,12 @@ func (lb *LoadBalancer) setServers(serverAddresses []string) bool {
return
true
return
true
}
}
// nextServer attempts to get the next server in the loadbalancer server list.
// If another goroutine has already updated the current server address to point at
// a different address than just failed, nothing is changed. Otherwise, a new server address
// is stored to the currentServerAddress field, and returned for use.
// This function must always be called by a goroutine that holds a read lock on the loadbalancer mutex.
func
(
lb
*
LoadBalancer
)
nextServer
(
failedServer
string
)
(
string
,
error
)
{
func
(
lb
*
LoadBalancer
)
nextServer
(
failedServer
string
)
(
string
,
error
)
{
lb
.
mutex
.
RLock
()
defer
lb
.
mutex
.
RUnlock
()
// note: these fields are not protected by the mutex, so we clamp the index value and update
// note: these fields are not protected by the mutex, so we clamp the index value and update
// the index/current address using local variables, to avoid time-of-check vs time-of-use
// the index/current address using local variables, to avoid time-of-check vs time-of-use
// race conditions caused by goroutine A incrementing it in between the time goroutine B
// race conditions caused by goroutine A incrementing it in between the time goroutine B
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment