mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 02:03:20 -04: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:
		| @@ -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 | ||||
| 	} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user