Skip to content

Commit c95b563

Browse files
committed
gbn: increase NACK wait time by 2X
1 parent 67afca8 commit c95b563

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
@@ -561,9 +561,19 @@ func (g *GoBackNConn) receivePacketsForever() error { // nolint:gocyclo
561561

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

568578
continue
569579
}

0 commit comments

Comments
 (0)