*(dnsforward): fix reading in-memory entries
This commit is contained in:
parent
9d8a95f836
commit
df427b6822
|
@ -208,14 +208,17 @@ func (l *queryLog) getData(params getDataParams) map[string]interface{} {
|
|||
memoryEntries := make([]*logEntry, 0)
|
||||
|
||||
// go through the buffer in the reverse order
|
||||
// from NEWER to OLDER
|
||||
for i := len(l.buffer) - 1; i >= 0; i-- {
|
||||
entry := l.buffer[i]
|
||||
if !matchesGetDataParams(entry, params) {
|
||||
|
||||
if entry.Time.UnixNano() >= params.OlderThan.UnixNano() {
|
||||
// Ignore entries newer than what was requested
|
||||
continue
|
||||
}
|
||||
|
||||
if entry.Time.UnixNano() >= params.OlderThan.UnixNano() {
|
||||
break
|
||||
if !matchesGetDataParams(entry, params) {
|
||||
continue
|
||||
}
|
||||
|
||||
memoryEntries = append(memoryEntries, entry)
|
||||
|
|
|
@ -15,7 +15,11 @@ import (
|
|||
// if we failed to find the desired record
|
||||
var ErrSeekNotFound = errors.New("Seek not found the record")
|
||||
|
||||
const bufferSize = 256 * 1024 // 256 KB is the buffer size
|
||||
// TODO: Find a way to grow buffer instead of relying on this value when reading strings
|
||||
const maxEntrySize = 16 * 1024
|
||||
|
||||
// buffer should be enough for at least this number of entries
|
||||
const bufferSize = 100 * maxEntrySize
|
||||
|
||||
// QLogFile represents a single query log file
|
||||
// It allows reading from the file in the reverse order
|
||||
|
|
|
@ -9,9 +9,6 @@ import (
|
|||
"github.com/AdguardTeam/golibs/log"
|
||||
)
|
||||
|
||||
// TODO: Check this when we append a new line -- we don't want to have a line longer than this
|
||||
const maxEntrySize = 1024
|
||||
|
||||
// flushLogBuffer flushes the current buffer to file and resets the current buffer
|
||||
func (l *queryLog) flushLogBuffer(fullFlush bool) error {
|
||||
l.fileFlushLock.Lock()
|
||||
|
|
Loading…
Reference in New Issue