coredns plugin -- don't reload from querylog on SIGUSR, we already have it in memory
This commit is contained in:
parent
4ecb84f9ad
commit
ea1125f57d
|
@ -36,6 +36,7 @@ func (top *hourTop) init() {
|
||||||
|
|
||||||
type dayTop struct {
|
type dayTop struct {
|
||||||
hours []*hourTop
|
hours []*hourTop
|
||||||
|
loaded bool
|
||||||
sync.RWMutex // write -- rotating hourTop, read -- anything else
|
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 {
|
func loadTopFromFiles() error {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
runningTop.RLock()
|
runningTop.RLock()
|
||||||
|
if runningTop.loaded {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
defer runningTop.RUnlock()
|
defer runningTop.RUnlock()
|
||||||
onEntry := func(entry *logEntry) error {
|
onEntry := func(entry *logEntry) error {
|
||||||
err := runningTop.addEntry(entry, now)
|
err := runningTop.addEntry(entry, now)
|
||||||
|
@ -226,6 +230,8 @@ func loadTopFromFiles() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runningTop.loaded = true
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue