Fix some connection bugs
This commit is contained in:
parent
873bfcc73c
commit
679c5f0ccd
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user