- autohosts: fix crash on startup if filesystem watcher couldn't be initialized
Close #1814 Squashed commit of the following: commit ba17a5b3c61a8a5282beb0cca470e2302e83c0d6 Author: Simon Zolin <s.zolin@adguard.com> Date: Fri Jun 19 10:08:44 2020 +0300 - autohosts: fix crash on startup if filesystem watcher couldn't be initialized
This commit is contained in:
parent
aa7b3c33d5
commit
2c47053cfe
@ -76,6 +76,7 @@ func (a *AutoHosts) Start() {
|
|||||||
go a.updateLoop()
|
go a.updateLoop()
|
||||||
a.updateChan <- true
|
a.updateChan <- true
|
||||||
|
|
||||||
|
if a.watcher != nil {
|
||||||
go a.watcherLoop()
|
go a.watcherLoop()
|
||||||
|
|
||||||
err := a.watcher.Add(a.hostsFn)
|
err := a.watcher.Add(a.hostsFn)
|
||||||
@ -89,13 +90,16 @@ func (a *AutoHosts) Start() {
|
|||||||
log.Error("Error while initializing watcher for a directory %s: %s", dir, err)
|
log.Error("Error while initializing watcher for a directory %s: %s", dir, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close - close module
|
// Close - close module
|
||||||
func (a *AutoHosts) Close() {
|
func (a *AutoHosts) Close() {
|
||||||
a.updateChan <- false
|
a.updateChan <- false
|
||||||
close(a.updateChan)
|
close(a.updateChan)
|
||||||
|
if a.watcher != nil {
|
||||||
_ = a.watcher.Close()
|
_ = a.watcher.Close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update table
|
// update table
|
||||||
|
Loading…
Reference in New Issue
Block a user