Skip to content

Commit 77d0bd5

Browse files
gbn: increase NACK wait time by 2X
1 parent 6f969c9 commit 77d0bd5

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

gbn/gbn_conn.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,19 @@ func (g *GoBackNConn) receivePacketsForever() error { // nolint:gocyclo
564564

565565
// If we recently sent a NACK for the same
566566
// sequence number then back off.
567-
if lastNackSeq == g.recvSeq &&
568-
time.Since(lastNackTime) <
569-
g.cfg.resendTimeout {
567+
// We wait 2 times the resendTimeout before
568+
// sending a new nack, as this case is likely
569+
// hit if the sender is currently resending
570+
// the queue, and therefore the threads that
571+
// are resending the queue is likely busy with
572+
// the resend, and therefore won't react to the
573+
// NACK we send here in time.
574+
sinceSent := time.Since(lastNackTime)
575+
recentlySent := sinceSent <
576+
g.cfg.resendTimeout*2
577+
578+
if lastNackSeq == g.recvSeq && recentlySent {
579+
g.log.Tracef("Recently sent NACK")
570580

571581
continue
572582
}

0 commit comments

Comments
 (0)