From 679c5f0ccd091dd8d0b4727145519ddd2f668813 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Wed, 31 Jul 2019 16:49:48 +0100 Subject: [PATCH] Fix some connection bugs --- network/default.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/network/default.go b/network/default.go index 415824a9..78553653 100644 --- a/network/default.go +++ b/network/default.go @@ -55,6 +55,8 @@ func (n *network) process(advertChan <-chan *router.Advert) { Timestamp: a.Timestamp.UnixNano(), Events: events, }) + case <-n.exit: + return } } } @@ -78,10 +80,12 @@ func (n *network) Connect() error { defer n.Unlock() // check if we're connected - if !n.connected { + if n.connected { return nil } + n.exit = make(chan bool) + // start advertising advertChan, err := n.options.Router.Advertise() if err != nil { @@ -111,6 +115,8 @@ func (n *network) Close() error { return nil } + close(n.exit) + // set connected to false n.connected = false