Pull request 2020: AG-26236-ring-buffer
Squashed commit of the following:
commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415
Merge: a6259ed57 39aeaf891
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Oct 3 20:39:58 2023 +0300
Merge branch 'master' into AG-26236-ring-buffer
commit a6259ed5758156e4110ee3ea6a49760d2880ade3
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Oct 3 20:30:20 2023 +0300
querylog: imp code
commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Oct 3 20:11:49 2023 +0300
querylog: fix typo
commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Oct 3 20:05:22 2023 +0300
querylog: imp err msg
commit 02913d35b43e190e42765823ccfcdd332839e984
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Oct 3 19:37:47 2023 +0300
aghalg: imp tests
commit 98a7909088d2a65b78afa9fa3113545c94429e65
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Oct 3 19:23:10 2023 +0300
all: imp tests
commit e147804eeafe89e5020cd917784eef3ff2b310d0
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Oct 3 18:49:49 2023 +0300
all: imp code
commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Oct 3 14:39:43 2023 +0300
all: add tests
commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Mon Oct 2 17:43:09 2023 +0300
all: imp code
commit 21e51fcbe411258eaf830825df9d05b7ddcc187a
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Fri Sep 29 18:21:00 2023 +0300
all: add ring buffer
This commit is contained in:
@@ -51,13 +51,12 @@ func (l *queryLog) searchMemory(params *searchParams, cache clientCache) (entrie
|
||||
l.bufferLock.Lock()
|
||||
defer l.bufferLock.Unlock()
|
||||
|
||||
// Go through the buffer in the reverse order, from newer to older.
|
||||
var err error
|
||||
for i := len(l.buffer) - 1; i >= 0; i-- {
|
||||
l.buffer.ReverseRange(func(entry *logEntry) (cont bool) {
|
||||
// A shallow clone is enough, since the only thing that this loop
|
||||
// modifies is the client field.
|
||||
e := l.buffer[i].shallowClone()
|
||||
e := entry.shallowClone()
|
||||
|
||||
var err error
|
||||
e.client, err = l.client(e.ClientID, e.IP.String(), cache)
|
||||
if err != nil {
|
||||
msg := "querylog: enriching memory record at time %s" +
|
||||
@@ -70,9 +69,11 @@ func (l *queryLog) searchMemory(params *searchParams, cache clientCache) (entrie
|
||||
if params.match(e) {
|
||||
entries = append(entries, e)
|
||||
}
|
||||
}
|
||||
|
||||
return entries, len(l.buffer)
|
||||
return true
|
||||
})
|
||||
|
||||
return entries, l.buffer.Len()
|
||||
}
|
||||
|
||||
// search - searches log entries in the query log using specified parameters
|
||||
|
||||
Reference in New Issue
Block a user