浏览代码

send more ack seg

Darien Raymond 9 年之前
父节点
当前提交
3be9519ed4
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      transport/internet/kcp/receiving.go

+ 7 - 1
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 {