Skip to content

Commit

Permalink
PR #321: Cleanup TCP proxy connection
Browse files Browse the repository at this point in the history
This patch updates the conns map when the connection is closed.
  • Loading branch information
Crypto89 authored and magiconair committed Jul 24, 2017
1 parent eca27f5 commit 327c81a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion proxy/tcp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,20 @@ func (s *Server) Serve(l net.Listener) error {
}
s.conns[c] = true
s.mu.Unlock()
go s.Handler.ServeTCP(c)

go func() {
defer func() {
// Explicitly close the connection
c.Close()

// Delete the connection from the conns map
s.mu.Lock()
delete(s.conns, c)
s.mu.Unlock()
}()

s.Handler.ServeTCP(c)
}()
}
}

Expand Down

0 comments on commit 327c81a

Please sign in to comment.