From 88d212eb225a41dfc3a1484a3b2b7f317140c1c9 Mon Sep 17 00:00:00 2001 From: V2Ray Date: Sun, 13 Sep 2015 00:25:50 +0200 Subject: [PATCH] Clean up code --- net/freedom/freedom.go | 5 ++--- net/socks/socks.go | 5 ++--- net/vmess/vmessin.go | 5 ++--- net/vmess/vmessout.go | 5 ++--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/net/freedom/freedom.go b/net/freedom/freedom.go index 17fbb5ad0..8be772d4b 100644 --- a/net/freedom/freedom.go +++ b/net/freedom/freedom.go @@ -64,8 +64,7 @@ func (vconn *FreedomConnection) DumpOutput(conn net.Conn, output chan<- []byte, } func (vconn *FreedomConnection) CloseConn(conn net.Conn, finish <-chan bool) { - for i := 0; i < 2; i++ { - <-finish - } + <-finish + <-finish conn.Close() } diff --git a/net/socks/socks.go b/net/socks/socks.go index bbc189941..6bc888891 100644 --- a/net/socks/socks.go +++ b/net/socks/socks.go @@ -155,7 +155,6 @@ func (server *SocksServer) dumpOutput(conn net.Conn, output <-chan []byte, finis } func (server *SocksServer) waitForFinish(finish <-chan bool) { - for i := 0; i < 2; i++ { - <-finish - } + <-finish + <-finish } diff --git a/net/vmess/vmessin.go b/net/vmess/vmessin.go index 3e440e9c3..3ac96c969 100644 --- a/net/vmess/vmessin.go +++ b/net/vmess/vmessin.go @@ -120,9 +120,8 @@ func (handler *VMessInboundHandler) dumpOutput(writer io.Writer, output <-chan [ } func (handler *VMessInboundHandler) waitForFinish(finish <-chan bool) { - for i := 0; i < 2; i++ { - <-finish - } + <-finish + <-finish } type VMessInboundHandlerFactory struct { diff --git a/net/vmess/vmessout.go b/net/vmess/vmessout.go index 5284eadb3..16c07c90c 100644 --- a/net/vmess/vmessout.go +++ b/net/vmess/vmessout.go @@ -146,9 +146,8 @@ func (handler *VMessOutboundHandler) dumpInput(writer io.Writer, input <-chan [] } func (handler *VMessOutboundHandler) waitForFinish(finish <-chan bool) { - for i := 0; i < 2; i++ { - <-finish - } + <-finish + <-finish log.Debug("Finishing waiting for VMessOutbound ending.") }