mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-23 18:15:24 +00:00
Shut down listeners when stopping
This commit is contained in:
parent
b0df9e2f31
commit
b959f53fee
@ -194,7 +194,9 @@ func (c *Core) _stop() {
|
||||
if c.addPeerTimer != nil {
|
||||
c.addPeerTimer.Stop()
|
||||
}
|
||||
c.link.stop()
|
||||
for _, peer := range c.GetPeers() {
|
||||
c.DisconnectPeer(peer.Port)
|
||||
}
|
||||
c.log.Infoln("Stopped")
|
||||
}
|
||||
|
@ -134,6 +134,13 @@ func (l *link) create(msgIO linkInterfaceMsgIO, name, linkType, local, remote st
|
||||
return &intf, nil
|
||||
}
|
||||
|
||||
func (l *link) stop() error {
|
||||
if err := l.tcp.stop(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (intf *linkInterface) handler() error {
|
||||
// TODO split some of this into shorter functions, so it's easier to read, and for the FIXME duplicate peer issue mentioned later
|
||||
myLinkPub, myLinkPriv := crypto.NewBoxKeys()
|
||||
|
@ -96,6 +96,13 @@ func (t *tcp) init(l *link) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *tcp) stop() error {
|
||||
for _, listener := range t.listeners {
|
||||
close(listener.Stop)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *tcp) reconfigure() {
|
||||
t.link.core.config.Mutex.RLock()
|
||||
added := util.Difference(t.link.core.config.Current.Listen, t.link.core.config.Previous.Listen)
|
||||
|
Loading…
Reference in New Issue
Block a user