Commit b881a1ef authored by wangchenglong01's avatar wangchenglong01 Committed by GitHub

Add error check to avoid panic (#4584)

* Add error check to avoid panic
Signed-off-by: default avatarCookie Wang <luckymrwang@163.com>

* Add error check to avoid panic
Signed-off-by: default avatarCookie Wang <luckymrwang@163.com>
Co-authored-by: default avatarCookie Wang <luckymrwang@163.com>
parent 40edf1e5
......@@ -117,11 +117,14 @@ func (h *Hostsfile) readHosts() {
defer file.Close()
stat, err := file.Stat()
if err != nil {
return
}
h.RLock()
size := h.size
h.RUnlock()
if err == nil && h.mtime.Equal(stat.ModTime()) && size == stat.Size() {
if h.mtime.Equal(stat.ModTime()) && size == stat.Size() {
return
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment