1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-29 18:45:23 +00:00

shrink buf in time

This commit is contained in:
v2ray 2016-07-01 23:27:57 +02:00
parent 2169dcd7da
commit 8e98ede75d
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 9 additions and 1 deletions

View File

@ -279,6 +279,7 @@ func (kcp *KCP) Input(data []byte) int {
kcp.update_ack(_itimediff(kcp.current, ts))
}
kcp.parse_ack(sn)
kcp.shrink_buf()
if flag == 0 {
flag = 1
maxack = sn
@ -300,9 +301,9 @@ func (kcp *KCP) Input(data []byte) int {
}
kcp.HandleReceivingNext(seg.ReceivinNext)
kcp.HandleSendingNext(seg.SendingNext)
kcp.shrink_buf()
default:
}
kcp.shrink_buf()
}
if flag != 0 {

View File

@ -53,6 +53,10 @@ func (this *SendingWindow) Clear(una uint32) {
}
func (this *SendingWindow) Remove(idx uint32) {
if this.len == 0 {
return
}
pos := (this.start + idx) % this.cap
seg := this.data[pos]
if seg == nil {
@ -80,6 +84,9 @@ func (this *SendingWindow) Remove(idx uint32) {
}
func (this *SendingWindow) HandleFastAck(number uint32) {
if this.len == 0 {
return
}
for i := this.start; ; i = this.next[i] {
seg := this.data[i]