Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mixclient: Avoid jitter calculation panic #3448

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mixing/mixclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,11 @@ func (c *Client) prDelay(ctx context.Context, p *peer) error {
sendBefore := epoch.Add(-timeoutDuration - maxJitter)
sendAfter := epoch.Add(timeoutDuration)
var wait time.Duration
if now.After(sendBefore) {
if !now.Before(sendBefore) {
wait = sendAfter.Sub(now)
sendBefore = sendBefore.Add(c.epoch)
}
wait += p.msgJitter() + rand.Duration(time.Until(sendBefore))
wait += p.msgJitter() + rand.Duration(sendBefore.Sub(now))
timer := time.NewTimer(wait)
select {
case <-ctx.Done():
Expand Down