Skip to content

Commit 8f8ecc9

Browse files
committed
gbn: increase NACK wait time by 2X
1 parent 64f45c2 commit 8f8ecc9

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

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

576586
continue
577587
}

0 commit comments

Comments
 (0)