From 9434f5156c60b04ff541b32f0950d3c5074e6cb6 Mon Sep 17 00:00:00 2001 From: v2ray Date: Tue, 12 Jul 2016 18:27:14 +0200 Subject: [PATCH] fix memory leak --- transport/internet/kcp/listener.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/transport/internet/kcp/listener.go b/transport/internet/kcp/listener.go index 320f9d1d..dc37bbec 100644 --- a/transport/internet/kcp/listener.go +++ b/transport/internet/kcp/listener.go @@ -64,6 +64,7 @@ func (this *Listener) OnReceive(payload *alloc.Buffer, src v2net.Destination) { conn, found := this.sessions[sourceId] if !found { writer := &Writer{ + id: sourceId, hub: this.hub, dest: src, listener: this, @@ -135,6 +136,7 @@ func (this *Listener) Addr() net.Addr { } type Writer struct { + id string dest v2net.Destination hub *udp.UDPHub listener *Listener @@ -145,7 +147,7 @@ func (this *Writer) Write(payload []byte) (int, error) { } func (this *Writer) Close() error { - this.listener.Remove(this.dest.NetAddr()) + this.listener.Remove(this.id) return nil }