Skip to content

Commit

Permalink
fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
DarienRaymond committed Jul 12, 2016
1 parent b9bf419 commit 9434f51
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion transport/internet/kcp/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -135,6 +136,7 @@ func (this *Listener) Addr() net.Addr {
}

type Writer struct {
id string
dest v2net.Destination
hub *udp.UDPHub
listener *Listener
Expand All @@ -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
}

Expand Down

0 comments on commit 9434f51

Please sign in to comment.