Pull request: querylog: opt mem buf

Merge in DNS/adguard-home from opt-querylog to master

Squashed commit of the following:

commit b4f02c3e5059833a696c0a3ddac24295a99b735a
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Dec 13 21:04:54 2021 +0300

    querylog: imp docs

commit 4d9356a684491814afd2037eccb8791f7f37bac4
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Dec 13 21:01:40 2021 +0300

    querylog: opt mem buf
This commit is contained in:
Ainar Garipov 2021-12-13 21:12:27 +03:00
parent f315601a9f
commit 8c5090d89f
1 changed files with 4 additions and 0 deletions

View File

@ -220,6 +220,10 @@ func (l *queryLog) Add(params *AddParams) {
if !l.conf.FileEnabled { if !l.conf.FileEnabled {
if len(l.buffer) > int(l.conf.MemSize) { if len(l.buffer) > int(l.conf.MemSize) {
// writing to file is disabled - just remove the oldest entry from array // writing to file is disabled - just remove the oldest entry from array
//
// TODO(a.garipov): This should be replaced by a proper ring buffer,
// but it's currently difficult to do that.
l.buffer[0] = nil
l.buffer = l.buffer[1:] l.buffer = l.buffer[1:]
} }
} else if !l.flushPending { } else if !l.flushPending {