diff options
author | Brad Fitzpatrick <[email protected]> | 2018-06-20 14:50:40 -0700 |
---|---|---|
committer | Brad Fitzpatrick <[email protected]> | 2018-06-20 14:50:40 -0700 |
commit | 7f81f7701c9b584822030be9a3a701b125a56c91 (patch) | |
tree | 30101517e1ee2eca177ab04a4a4943d2969725fe | |
parent | 7efa37ff5079eba4a39ddda1b79f65fc81c759e3 (diff) |
Work around deadlock with Go tip (at Go rev f3f7bd5)
Not sure the root cause yet. See golang/go#25985.
-rw-r--r-- | tcpproxy.go | 6 |
1 files 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 { |