mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-18 02:16:10 -05:00
refine ack seg put
This commit is contained in:
parent
13e83c17a5
commit
34fb72e7c6
@ -202,15 +202,10 @@ func (this *AckList) Clear(una uint32) {
|
||||
func (this *AckList) Flush(current uint32, rto uint32) {
|
||||
seg := NewAckSegment()
|
||||
this.Lock()
|
||||
for i := 0; i < len(this.numbers); i++ {
|
||||
for i := 0; i < len(this.numbers) && !seg.IsFull(); i++ {
|
||||
if this.nextFlush[i] <= current {
|
||||
seg.Count++
|
||||
seg.NumberList = append(seg.NumberList, this.numbers[i])
|
||||
seg.TimestampList = append(seg.TimestampList, this.timestamps[i])
|
||||
seg.PutNumber(this.numbers[i], this.timestamps[i])
|
||||
this.nextFlush[i] = current + rto/2
|
||||
if seg.Count == 128 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
this.Unlock()
|
||||
|
@ -109,6 +109,16 @@ func NewAckSegment() *AckSegment {
|
||||
return seg
|
||||
}
|
||||
|
||||
func (this *AckSegment) PutNumber(number uint32, timestamp uint32) {
|
||||
this.Count++
|
||||
this.NumberList = append(this.NumberList, number)
|
||||
this.TimestampList = append(this.TimestampList, timestamp)
|
||||
}
|
||||
|
||||
func (this *AckSegment) IsFull() bool {
|
||||
return this.Count == 128
|
||||
}
|
||||
|
||||
func (this *AckSegment) ByteSize() int {
|
||||
return 2 + 1 + 1 + 4 + 4 + 1 + int(this.Count)*4 + int(this.Count)*4
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user