1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-30 07:46:41 -04: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.update_ack(_itimediff(kcp.current, ts))
} }
kcp.parse_ack(sn) kcp.parse_ack(sn)
kcp.shrink_buf()
if flag == 0 { if flag == 0 {
flag = 1 flag = 1
maxack = sn maxack = sn
@ -300,9 +301,9 @@ func (kcp *KCP) Input(data []byte) int {
} }
kcp.HandleReceivingNext(seg.ReceivinNext) kcp.HandleReceivingNext(seg.ReceivinNext)
kcp.HandleSendingNext(seg.SendingNext) kcp.HandleSendingNext(seg.SendingNext)
kcp.shrink_buf()
default: default:
} }
kcp.shrink_buf()
} }
if flag != 0 { if flag != 0 {

View File

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