Skip to content

Commit

Permalink
add randomization on list of dmsg servers for connect
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpalide committed Feb 1, 2024
1 parent ee0160c commit b6a6764
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/dmsg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
"math/rand"
"net"
"sync"
"time"
Expand Down Expand Up @@ -176,7 +177,10 @@ func (ce *Client) Serve(ctx context.Context) {
}
} else {
entries, err = ce.discoverServers(cancellabelCtx, false)

// randomize dmsg servers list
rand.Shuffle(len(entries), func(i, j int) {
entries[i], entries[j] = entries[j], entries[i]
})
if err != nil {
ce.log.WithError(err).Warn("Failed to discover dmsg servers.")
if err == context.Canceled || err == context.DeadlineExceeded {
Expand Down

0 comments on commit b6a6764

Please sign in to comment.