1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00

Clear sending queue when peer closed

This commit is contained in:
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
}