From 7a5c910cd5fa58ecf5e78d2f244e6476de4baec4 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Sat, 7 Nov 2015 12:44:13 +0000 Subject: [PATCH] tiny refactor: inline a tiny single-use fun and move another --- router/connection.go | 17 +++-------------- router/sleeve.go | 7 +++++++ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/router/connection.go b/router/connection.go index 6c6de9e5..6c9fb962 100644 --- a/router/connection.go +++ b/router/connection.go @@ -379,7 +379,9 @@ func (conn *LocalConnection) shutdown(err error) { conn.Router.Ourself.DeleteConnection(conn) } - stopTicker(conn.heartbeatTCP) + if conn.heartbeatTCP != nil { + conn.heartbeatTCP.Stop() + } if conn.forwarder != nil { conn.forwarder.Stop() @@ -451,16 +453,3 @@ func (conn *LocalConnection) handleProtocolMsg(tag ProtocolTag, payload []byte) func (conn *LocalConnection) extendReadDeadline() { conn.TCPConn.SetReadDeadline(time.Now().Add(TCPHeartbeat * 2)) } - -func tickerChan(ticker *time.Ticker) <-chan time.Time { - if ticker != nil { - return ticker.C - } - return nil -} - -func stopTicker(ticker *time.Ticker) { - if ticker != nil { - ticker.Stop() - } -} diff --git a/router/sleeve.go b/router/sleeve.go index 4dd22340..ffc11f7f 100644 --- a/router/sleeve.go +++ b/router/sleeve.go @@ -1126,3 +1126,10 @@ func timerChan(timer *time.Timer) <-chan time.Time { } return nil } + +func tickerChan(ticker *time.Ticker) <-chan time.Time { + if ticker != nil { + return ticker.C + } + return nil +}