Skip to content

Commit a351b99

Browse files
committed
gbn: increase NACK wait time by 2X
1 parent bb8b440 commit a351b99

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
@@ -579,8 +579,18 @@ func (g *GoBackNConn) receivePacketsForever() error { // nolint:gocyclo
579579

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

585595
continue
586596
}

0 commit comments

Comments
 (0)