Pull request 2119: 6570-querylog-size-memory
Updates #6570. Squashed commit of the following: commit 92b2723ac1b2a78138a55cb82a3222f66119bbda Merge: 2da12283b0143c3aacAuthor: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jan 9 17:07:23 2024 +0300 Merge branch 'master' into 6570-querylog-size-memory commit 2da12283b5f504fa77f08fa6026fa9a57b806b38 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jan 9 17:04:54 2024 +0300 all: imp tests commit 1cb404c65d4e9981b709d689fd281253eca01f82 Merge: 5f7d2051694d437d40Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Dec 28 20:18:00 2023 +0300 Merge branch 'master' into 6570-querylog-size-memory commit 5f7d20516934867e1a141c19a97edb49407884ee Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Dec 27 15:07:54 2023 +0300 all: imp docs commit 0b17cfc4243a88606c62e4b1ae893a09149655b5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Dec 25 20:06:09 2023 +0300 all: querylog size memory
This commit is contained in:
@@ -63,7 +63,7 @@ type Config struct {
|
||||
|
||||
// MemSize is the number of entries kept in a memory buffer before they are
|
||||
// flushed to disk.
|
||||
MemSize int
|
||||
MemSize uint
|
||||
|
||||
// Enabled tells if the query log is enabled.
|
||||
Enabled bool
|
||||
@@ -143,14 +143,17 @@ func newQueryLog(conf Config) (l *queryLog, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
if conf.MemSize < 0 {
|
||||
return nil, errors.Error("memory size must be greater or equal to zero")
|
||||
memSize := conf.MemSize
|
||||
if memSize == 0 {
|
||||
// If query log is enabled, we still need to write entries to a file.
|
||||
// And all writing goes through a buffer.
|
||||
memSize = 1
|
||||
}
|
||||
|
||||
l = &queryLog{
|
||||
findClient: findClient,
|
||||
|
||||
buffer: aghalg.NewRingBuffer[*logEntry](conf.MemSize),
|
||||
buffer: aghalg.NewRingBuffer[*logEntry](memSize),
|
||||
|
||||
conf: &Config{},
|
||||
confMu: &sync.RWMutex{},
|
||||
|
||||
Reference in New Issue
Block a user