Skip to content

Fix round robin addresses in dual stack dialing#1995

Merged
erikdubbelboer merged 1 commit intovalyala:masterfrom
raviqqe:bug/round-robined-round-robin-dual-stack
Apr 11, 2025
Merged

Fix round robin addresses in dual stack dialing#1995
erikdubbelboer merged 1 commit intovalyala:masterfrom
raviqqe:bug/round-robined-round-robin-dual-stack

Conversation

@raviqqe
Copy link
Copy Markdown
Contributor

@raviqqe raviqqe commented Apr 11, 2025

This PR fixes round robin addresses in dual stack dialing.

Question

What and where is the best way to unit-test this fix?

References

n := uint32(len(addrs)) // #nosec G115
for n > 0 {
for range n {
conn, err = d.tryDial(network, addrs[idx%n].String(), deadline, d.concurrencyCh)
Copy link
Copy Markdown
Contributor Author

@raviqqe raviqqe Apr 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this statement, the variable n should not change over different iterations of the loop while we want to try n addresses.

For example, in the previous implementation, if n is 2 and the initial idx is 2,

  1. In the first iteration, idx % n = 2 % 2 = 0.
  2. In the second iteration, idx % n = 3 % 1 = 0. ;(

@erikdubbelboer
Copy link
Copy Markdown
Collaborator

Nice find!

@erikdubbelboer erikdubbelboer merged commit e380d34 into valyala:master Apr 11, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants