Skip to content

Commit

Permalink
hedge: fix retry logic in SendToLeader
Browse files Browse the repository at this point in the history
  • Loading branch information
flowerinthenight committed Jul 20, 2024
1 parent a352a0c commit 0cfc4de
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions hedge.go
Original file line number Diff line number Diff line change
Expand Up @@ -1417,22 +1417,22 @@ func SendToLeader(ctx context.Context, op *Op, m []byte, args ...*SendToLeaderAr

var i int
for {
if i >= retries {
if i >= retries && retries >= 0 {
break
}

if !op.IsRunning() {
time.Sleep(bo.Pause())
}

if retries > -1 {
if retries >= 0 {
i++
}
}

i = 0
for {
if i >= retries {
if i >= retries && retries >= 0 {
err = fmt.Errorf("hedge: retries exhausted")
return
}
Expand All @@ -1446,7 +1446,7 @@ func SendToLeader(ctx context.Context, op *Op, m []byte, args ...*SendToLeaderAr
return
}

if retries > -1 {
if retries >= 0 {
i++
}
}
Expand Down

0 comments on commit 0cfc4de

Please sign in to comment.