prevent putting back nil value

This commit is contained in:
xtaci
2019-11-05 19:23:10 +08:00
parent ddb5eedad0
commit 68589db576
+6 -2
View File
@@ -1055,10 +1055,14 @@ func (kcp *KCP) remove_front(q []segment, n int) []segment {
// Release all cached outgoing segments
func (kcp *KCP) ReleaseTX() {
for k := range kcp.snd_queue {
xmitBuf.Put(kcp.snd_queue[k].data)
if kcp.snd_queue[k].data != nil {
xmitBuf.Put(kcp.snd_queue[k].data)
}
}
for k := range kcp.snd_buf {
xmitBuf.Put(kcp.snd_buf[k].data)
if kcp.snd_buf[k].data != nil {
xmitBuf.Put(kcp.snd_buf[k].data)
}
}
kcp.snd_queue = nil
kcp.snd_buf = nil