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 {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue