Clear sending queue when peer closed

pull/215/head v1.17.2
v2ray 2016-06-23 23:17:17 +02:00
parent ab710f2714
commit 0613d0cf22
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 16 additions and 0 deletions

View File

@ -358,6 +358,9 @@ func (this *Connection) MarkPeerClose() {
if this.state == ConnStateActive {
this.state = ConnStatePeerClosed
}
this.kcpAccess.Lock()
this.kcp.ClearSendQueue()
this.kcpAccess.Unlock()
}
func (this *Connection) kcpInput(data []byte) {

View File

@ -842,3 +842,16 @@ func (kcp *KCP) WndSize(sndwnd, rcvwnd int) int {
func (kcp *KCP) WaitSnd() int {
return len(kcp.snd_buf) + len(kcp.snd_queue)
}
func (this *KCP) ClearSendQueue() {
for _, seg := range this.snd_queue {
seg.Release()
}
this.snd_queue = nil
for _, seg := range this.snd_buf {
seg.Release()
}
this.snd_buf = nil
}