From 35b3a2d6a67ebfd7886f4554282a00506a8390ad Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 10 Jun 2015 12:18:09 +0100 Subject: [PATCH] Inline GossipSender.flush() and don't try to send nil --- router/gossip.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/router/gossip.go b/router/gossip.go index 684bb21d..e119e661 100644 --- a/router/gossip.go +++ b/router/gossip.go @@ -63,7 +63,14 @@ func (sender *GossipSender) run() { } sender.send(pending) case ch := <-sender.flushch: - sender.flush() + // ensure anything pending is sent, then close the channel we were given + select { + case pending := <-sender.cell: + if pending != nil { + sender.send(pending) + } + default: + } close(ch) } } @@ -341,14 +348,3 @@ func (router *Router) sendPendingGossip() { <-ch } } - -func (sender *GossipSender) flush() { - for { - select { - case pending := <-sender.cell: - sender.send(pending) - default: - return - } - } -}