coredns plugin -- don't reload from querylog on SIGUSR, we already have it in memory

This commit is contained in:
Eugene Bujak 2018-10-08 04:24:37 +03:00
parent 4ecb84f9ad
commit ea1125f57d
1 changed files with 6 additions and 0 deletions

View File

@ -36,6 +36,7 @@ func (top *hourTop) init() {
type dayTop struct {
hours []*hourTop
loaded bool
sync.RWMutex // write -- rotating hourTop, read -- anything else
}
@ -209,6 +210,9 @@ func (r *dayTop) addEntry(entry *logEntry, now time.Time) error {
func loadTopFromFiles() error {
now := time.Now()
runningTop.RLock()
if runningTop.loaded {
return nil
}
defer runningTop.RUnlock()
onEntry := func(entry *logEntry) error {
err := runningTop.addEntry(entry, now)
@ -226,6 +230,8 @@ func loadTopFromFiles() error {
return err
}
runningTop.loaded = true
return nil
}