mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-07-17 11:18:55 +00:00
mKCP transport: Make sure ACKs are limited within MTU (#5773)
https://github.com/XTLS/Xray-core/pull/5657#issuecomment-3984236113
This commit is contained in:
@@ -47,15 +47,18 @@ type AckList struct {
|
||||
|
||||
flushCandidates []uint32
|
||||
dirty bool
|
||||
|
||||
mss uint32
|
||||
}
|
||||
|
||||
func NewAckList(writer SegmentWriter) *AckList {
|
||||
func NewAckList(writer SegmentWriter, mss uint32) *AckList {
|
||||
return &AckList{
|
||||
writer: writer,
|
||||
timestamps: make([]uint32, 0, 128),
|
||||
numbers: make([]uint32, 0, 128),
|
||||
nextFlush: make([]uint32, 0, 128),
|
||||
flushCandidates: make([]uint32, 0, 128),
|
||||
mss: mss,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +93,7 @@ func (l *AckList) Clear(una uint32) {
|
||||
func (l *AckList) Flush(current uint32, rto uint32) {
|
||||
l.flushCandidates = l.flushCandidates[:0]
|
||||
|
||||
seg := NewAckSegment()
|
||||
seg := NewAckSegment((int(l.mss) - 17) / 4)
|
||||
for i := 0; i < len(l.numbers); i++ {
|
||||
if l.nextFlush[i] > current {
|
||||
if len(l.flushCandidates) < cap(l.flushCandidates) {
|
||||
@@ -109,7 +112,7 @@ func (l *AckList) Flush(current uint32, rto uint32) {
|
||||
if seg.IsFull() {
|
||||
l.writer.Write(seg)
|
||||
seg.Release()
|
||||
seg = NewAckSegment()
|
||||
seg = NewAckSegment((int(l.mss) - 17) / 4)
|
||||
l.dirty = false
|
||||
}
|
||||
}
|
||||
@@ -144,7 +147,7 @@ func NewReceivingWorker(kcp *Connection) *ReceivingWorker {
|
||||
window: NewReceivingWindow(),
|
||||
windowSize: kcp.Config.GetReceivingInFlightSize(),
|
||||
}
|
||||
worker.acklist = NewAckList(worker)
|
||||
worker.acklist = NewAckList(worker, kcp.mss+DataSegmentOverhead)
|
||||
return worker
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user