Fix early close

This commit is contained in:
世界 2022-08-24 18:54:02 +08:00
parent d5efb43122
commit b2bb9b3d2a
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 12 additions and 5 deletions

View file

@ -68,7 +68,9 @@ func (m *defaultInterfaceMonitor) delayCheckUpdate() error {
}
func (m *defaultInterfaceMonitor) Close() error {
if m.element != nil {
m.networkMonitor.UnregisterCallback(m.element)
}
return nil
}

View file

@ -45,10 +45,15 @@ func (m *networkUpdateMonitor) Start() error {
}
func (m *networkUpdateMonitor) Close() error {
return E.Errors(
m.routeListener.Unregister(),
m.interfaceListener.Unregister(),
)
if m.routeListener != nil {
m.routeListener.Unregister()
m.routeListener = nil
}
if m.interfaceListener != nil {
m.interfaceListener.Unregister()
m.interfaceListener = nil
}
return nil
}
func (m *defaultInterfaceMonitor) checkUpdate() error {