mirror of
https://github.com/go-micro/go-micro.git
synced 2025-08-10 21:52:01 +02:00
Fix some connection bugs
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user