From 503eb93735aeb00fb7b2f592509773930554539b Mon Sep 17 00:00:00 2001 From: Yilun Date: Thu, 16 Jul 2020 15:48:20 -0700 Subject: [PATCH] Fix tcp connection not closing correctly Signed-off-by: Yilun --- go.mod | 2 +- go.sum | 4 ++-- tunnel.go | 10 ++-------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 86003c9..8712def 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,6 @@ go 1.13 require ( github.com/nknorg/ncp-go v1.0.1 github.com/nknorg/nkn-sdk-go v1.3.0 - github.com/nknorg/nkn-tuna-session v0.0.0-20200716030938-96a9604ca2d3 + github.com/nknorg/nkn-tuna-session v0.1.0 github.com/nknorg/tuna v0.0.0-20200714222241-1d03b8a3603c ) diff --git a/go.sum b/go.sum index 4bddec3..5faaff7 100644 --- a/go.sum +++ b/go.sum @@ -77,8 +77,8 @@ github.com/nknorg/ncp-go v1.0.1 h1:oJKmcaAcVC1oCJiJ4tDvot7kved8uUGBYXldDHxc8vM= github.com/nknorg/ncp-go v1.0.1/go.mod h1:LfiwrFlKZAAoMwhCBA959jSzVD8E9RGOH9nyfXkQSfY= github.com/nknorg/nkn-sdk-go v1.3.0 h1:iT/MqUx7VyqVo3ivz3VIBbB+VvaByld0YrQiVIlfdCI= github.com/nknorg/nkn-sdk-go v1.3.0/go.mod h1:SeHZ25YcKIXDauhPw/v4XZjprWd+DtLDPNs3/U9/5qE= -github.com/nknorg/nkn-tuna-session v0.0.0-20200716030938-96a9604ca2d3 h1:N8Sx6cCtXVpZaROLUW5CAX4Ed0tdqlkqWw3IXyPcC3Y= -github.com/nknorg/nkn-tuna-session v0.0.0-20200716030938-96a9604ca2d3/go.mod h1:yKHEfiZt7xKgfzi1ONoXp1MuXwki7t8gmmmYtOcnYCM= +github.com/nknorg/nkn-tuna-session v0.1.0 h1:SF4G1jbh0H6vP92vN9QJ1h+zEfofzRaSbr4pGs1omNM= +github.com/nknorg/nkn-tuna-session v0.1.0/go.mod h1:yKHEfiZt7xKgfzi1ONoXp1MuXwki7t8gmmmYtOcnYCM= github.com/nknorg/nkn/v2 v2.0.0-20200703083743-f83cde273fe2 h1:YJL1RuRWLXcjRjm52aPn9JYryS41HBgfQvIVd5kGxZE= github.com/nknorg/nkn/v2 v2.0.0-20200703083743-f83cde273fe2/go.mod h1:LxKZTpn5VZTAbjsACSFL5nlQAQ4+WQKyIpVZUYopXm4= github.com/nknorg/nkn/v2 v2.0.2 h1:0bwUFFYkeVO6z+Odi52zHQ6IFs254D8GQfX5pfdfe+E= diff --git a/tunnel.go b/tunnel.go index bde91b2..f600642 100644 --- a/tunnel.go +++ b/tunnel.go @@ -6,7 +6,6 @@ import ( "log" "net" "strings" - "sync" "github.com/nknorg/ncp-go" nkn "github.com/nknorg/nkn-sdk-go" @@ -143,17 +142,12 @@ func (t *Tunnel) Start() error { } func pipe(a, b net.Conn) { - var wg sync.WaitGroup - wg.Add(2) go func() { - defer wg.Done() io.Copy(a, b) + a.Close() }() go func() { - defer wg.Done() io.Copy(b, a) + b.Close() }() - wg.Wait() - a.Close() - b.Close() }