From ff7d02179859a1169e21156274c1509a99e98c3c Mon Sep 17 00:00:00 2001 From: Dingjun Date: Mon, 7 Aug 2017 11:16:14 +0800 Subject: [PATCH] close channel instead of send something --- client.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/client.go b/client.go index a172104..8bcdebc 100644 --- a/client.go +++ b/client.go @@ -75,10 +75,7 @@ func (cc *Client) Run() error { go cc.registerSignal() go func() { cc.sshConn.Wait() - select { - case cc.ch <- struct{}{}: - default: - } + close(cc.ch) }() // wait exit signal @@ -308,10 +305,7 @@ func (cc *Client) keepAlive(interval time.Duration, maxCount int) { Log(ERROR, "keep alive hit max count, exit") cc.sshConn.Close() // send exit signal - select { - case cc.ch <- struct{}{}: - default: - } + close(cc.ch) return } } @@ -325,9 +319,6 @@ func (cc *Client) registerSignal() { case s1 := <-c: cc.err = fmt.Errorf("signal %v", s1) Log(ERROR, "signal %d received, exit", s1) - select { - case cc.ch <- struct{}{}: - default: - } + close(cc.ch) } }