Skip to content

Commit f449c3a

Browse files
committed
gbn: increase NACK wait time by 2X
1 parent 1d64aa0 commit f449c3a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

gbn/gbn_conn.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,18 @@ func (g *GoBackNConn) receivePacketsForever() error { // nolint:gocyclo
580580

581581
// If we recently sent a NACK for the same
582582
// sequence number then back off.
583-
if lastNackSeq == g.recvSeq &&
584-
time.Since(lastNackTime) < g.resendTimeout {
583+
// We wait 2 times the resendTimeout before
584+
// sending a new nack, as this case is likely
585+
// hit if the sender is currently resending
586+
// the queue, and therefore the threads that
587+
// are resending the queue is likely busy with
588+
// the resend, and therefore won't react to the
589+
// NACK we send here in time.
590+
sinceSent := time.Since(lastNackTime)
591+
recentlySent := sinceSent < g.resendTimeout*2 //nolint:gomnd
592+
593+
if lastNackSeq == g.recvSeq && recentlySent {
594+
log.Tracef("Recently sent NACK")
585595

586596
continue
587597
}

0 commit comments

Comments
 (0)