mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
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: Miek Gieben <miek@miek.nl>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user