From f3cccbb51c032ee61fd2fa948b2e721b2b975cd5 Mon Sep 17 00:00:00 2001 From: xtaci Date: Thu, 19 Dec 2019 14:52:45 +0800 Subject: [PATCH] fix closing scheme --- client/main.go | 3 ++- server/main.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/main.go b/client/main.go index f286f44..308243a 100644 --- a/client/main.go +++ b/client/main.go @@ -71,10 +71,11 @@ func handleClient(mux generic.Mux, p1 net.Conn, ctrl *generic.CopyControl, quiet } } } + p1.Close() + p2.Close() } go streamCopy(p1, p2) - // errors reading from p1(net.Conn) can close p2 while return streamCopy(p2, p1) } diff --git a/server/main.go b/server/main.go index b32f88c..9fb470e 100644 --- a/server/main.go +++ b/server/main.go @@ -138,10 +138,11 @@ func handleClient(p1 io.ReadWriteCloser, p2 net.Conn, ctrl *generic.CopyControl, } } } + p1.Close() + p2.Close() } go streamCopy(p2, p1) - // errors reading from p2(net.Conn) can close p1 while return streamCopy(p1, p2) }