Commit 6d218920 authored by Miek Gieben's avatar Miek Gieben Committed by Yong Tang

plugin/hosts: fix data race on h.size (#2573)

Guard the access of h.size as this is now a data race.

Fixes #2571
Signed-off-by: default avatarMiek Gieben <miek@miek.nl>
parent 2743c8ea
......@@ -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
}
......
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