aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugin/hosts/hostsfile.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/plugin/hosts/hostsfile.go b/plugin/hosts/hostsfile.go
index 5e0fd5bf6..421f8a77c 100644
--- a/plugin/hosts/hostsfile.go
+++ b/plugin/hosts/hostsfile.go
@@ -129,7 +129,10 @@ func (h *Hostsfile) readHosts() {
defer file.Close()
stat, err := file.Stat()
- if err == nil && h.mtime.Equal(stat.ModTime()) && h.size == stat.Size() {
+ h.RLock()
+ size := h.size
+ h.RUnlock()
+ if err == nil && h.mtime.Equal(stat.ModTime()) && size == stat.Size() {
return
}