Pull request 1799: AG-21072-stats-conf-race

Merge in DNS/adguard-home from AG-21072-stats-conf-race to master

Squashed commit of the following:

commit 26843b70ab8bfe0fa110c4156f2fd3f53ec5ee74
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Tue Apr 4 20:30:22 2023 +0300

    all: imp docs, locks

commit 942a5baa9606376dd06a3ef3284c17133014f768
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Tue Apr 4 19:15:18 2023 +0300

    stats: fix conf races
This commit is contained in:
Ainar Garipov
2023-04-05 15:50:14 +03:00
parent 27dbb427a1
commit 91ecbede7d
8 changed files with 128 additions and 91 deletions

View File

@@ -12,7 +12,6 @@ import (
"github.com/AdguardTeam/AdGuardHome/internal/filtering"
"github.com/AdguardTeam/golibs/errors"
"github.com/AdguardTeam/golibs/log"
"github.com/AdguardTeam/golibs/stringutil"
"github.com/AdguardTeam/golibs/timeutil"
"github.com/miekg/dns"
)
@@ -126,9 +125,7 @@ func (l *queryLog) WriteDiskConfig(c *Config) {
defer l.confMu.RUnlock()
*c = *l.conf
// TODO(a.garipov): Add stringutil.Set.Clone.
c.Ignored = stringutil.NewSet(l.conf.Ignored.Values()...)
c.Ignored = l.conf.Ignored.Clone()
}
// Clear memory buffer and remove log files

View File

@@ -33,6 +33,8 @@ type QueryLog interface {
}
// Config is the query log configuration structure.
//
// Do not alter any fields of this structure after using it.
type Config struct {
// Ignored is the list of host names, which should not be written to log.
Ignored *stringutil.Set