mirror of
https://github.com/coredns/coredns.git
synced 2025-10-26 13:51:05 +01:00
Add error check to avoid panic (#4584)
* Add error check to avoid panic Signed-off-by: Cookie Wang <luckymrwang@163.com> * Add error check to avoid panic Signed-off-by: Cookie Wang <luckymrwang@163.com> Co-authored-by: Cookie Wang <luckymrwang@163.com>
This commit is contained in:
parent
40edf1e566
commit
b881a1ef13
@ -117,11 +117,14 @@ func (h *Hostsfile) readHosts() {
|
|||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
stat, err := file.Stat()
|
stat, err := file.Stat()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
h.RLock()
|
h.RLock()
|
||||||
size := h.size
|
size := h.size
|
||||||
h.RUnlock()
|
h.RUnlock()
|
||||||
|
|
||||||
if err == nil && h.mtime.Equal(stat.ModTime()) && size == stat.Size() {
|
if h.mtime.Equal(stat.ModTime()) && size == stat.Size() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user