From 7f81f7701c9b584822030be9a3a701b125a56c91 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 20 Jun 2018 14:50:40 -0700 Subject: Work around deadlock with Go tip (at Go rev f3f7bd5) Not sure the root cause yet. See golang/go#25985. --- tcpproxy.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tcpproxy.go b/tcpproxy.go index 40a6c2c..9bfa26b 100644 --- a/tcpproxy.go +++ b/tcpproxy.go @@ -347,6 +347,8 @@ func UnderlyingConn(c net.Conn) net.Conn { return c } +func goCloseConn(c net.Conn) { go c.Close() } + // HandleConn implements the Target interface. func (dp *DialProxy) HandleConn(src net.Conn) { ctx := context.Background() @@ -362,13 +364,13 @@ func (dp *DialProxy) HandleConn(src net.Conn) { dp.onDialError()(src, err) return } - defer dst.Close() + defer goCloseConn(dst) if err = dp.sendProxyHeader(dst, src); err != nil { dp.onDialError()(src, err) return } - defer src.Close() + defer goCloseConn(src) if ka := dp.keepAlivePeriod(); ka > 0 { if c, ok := UnderlyingConn(src).(*net.TCPConn); ok { -- cgit v1.2.3