5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 09:30:28 +00:00

close listener when a multicast interface is removed

This commit is contained in:
Arceliar 2020-05-24 14:09:06 -05:00
parent 169b8747d4
commit c2d6e9e8f1

View File

@ -136,6 +136,7 @@ func (m *Multicast) _stop() error {
m.log.Infoln("Stopping multicast module") m.log.Infoln("Stopping multicast module")
m.isOpen = false m.isOpen = false
for name := range m.listeners { for name := range m.listeners {
m.listeners[name].listener.Listener.Close()
close(m.listeners[name].stop) close(m.listeners[name].stop)
delete(m.listeners, name) delete(m.listeners, name)
} }
@ -213,6 +214,7 @@ func (m *Multicast) _monitorInterfaceChanges() {
for name, intf := range m.listeners { for name, intf := range m.listeners {
if _, ok := m._interfaces[name]; !ok { if _, ok := m._interfaces[name]; !ok {
// This is a disappeared interface. Stop the announcer. // This is a disappeared interface. Stop the announcer.
intf.listener.Listener.Close()
close(intf.stop) close(intf.stop)
delete(m.listeners, name) delete(m.listeners, name)
m.log.Debugln("Stopped multicasting on", name) m.log.Debugln("Stopped multicasting on", name)