Skip to content

Commit

Permalink
Ensures that we copy the value of APIInfo into a new reference in order
Browse files Browse the repository at this point in the history
to avoid testing races in the raftlease client tests.
  • Loading branch information
manadart committed Jan 5, 2022
1 parent 672fe14 commit 471522c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions api/raftlease/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,8 @@ func (r *remote) loop() error {
func (r *remote) connect() bool {
stop := make(chan struct{})

var info *api.Info
r.mutex.Lock()
info = r.config.APIInfo
info := *r.config.APIInfo
r.stopConnecting = stop
r.mutex.Unlock()

Expand All @@ -621,7 +620,7 @@ func (r *remote) connect() bool {
_ = retry.Call(retry.CallArgs{
Func: func() error {
r.config.Logger.Debugf("open api to %v", address)
conn, err := api.Open(info, api.DialOpts{
conn, err := api.Open(&info, api.DialOpts{
DialAddressInterval: 50 * time.Millisecond,
Timeout: 10 * time.Minute,
RetryDelay: 2 * time.Second,
Expand Down

0 comments on commit 471522c

Please sign in to comment.