소스 검색

fix memory leak

v2ray 9 년 전
부모
커밋
9434f5156c
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      transport/internet/kcp/listener.go

+ 3 - 1
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
 }