From 3be9519ed4398b7b9cefd904039e34200b36cf9e Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Tue, 29 Nov 2016 08:31:19 +0100 Subject: [PATCH] send more ack seg --- transport/internet/kcp/receiving.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/transport/internet/kcp/receiving.go b/transport/internet/kcp/receiving.go index 62ae6d0b..b1417884 100644 --- a/transport/internet/kcp/receiving.go +++ b/transport/internet/kcp/receiving.go @@ -104,7 +104,7 @@ func (v *AckList) Flush(current uint32, rto uint32) { v.flushCandidates = v.flushCandidates[:0] seg := NewAckSegment() - for i := 0; i < len(v.numbers) && !seg.IsFull(); i++ { + for i := 0; i < len(v.numbers); i++ { if v.nextFlush[i] > current { if len(v.flushCandidates) < cap(v.flushCandidates) { v.flushCandidates = append(v.flushCandidates, v.numbers[i]) @@ -118,6 +118,12 @@ func (v *AckList) Flush(current uint32, rto uint32) { timeout = 20 } v.nextFlush[i] = current + timeout + + if seg.IsFull() { + v.writer.Write(seg) + seg.Release() + seg = NewAckSegment() + } } if seg.Count > 0 { for _, number := range v.flushCandidates {