docstring_tokens
stringlengths
0
76.5k
code_tokens
stringlengths
75
1.81M
label_window
sequencelengths
4
2.12k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
) (f func(name []byte, b *bbolt.Bucket) (err error)) { return func(name []byte, _ *bbolt.Bucket) (err error) {
<mask> func newBucketWalker( <mask> tx *bolt.Tx, <mask> unitDelPtr *int, <mask> firstID uint32, <mask> ) (f func(name []byte, b *bolt.Bucket) (err error)) { <mask> return func(name []byte, _ *bolt.Bucket) (err error) { <mask> nameID, ok := unitNameToID(name) <mask> if !ok || nameID < firstID { <mask> err = tx.DeleteBucket(name) <mask> if err != nil { <mask> log.Debug("stats: tx.DeleteBucket: %s", err) </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove tx *bolt.Tx, </s> add tx *bbolt.Tx, </s> remove firstID := id - s.conf.limit - 1 </s> add firstID := id - s.limitHours - 1 </s> remove func (s *statsCtx) dbOpen() bool { var err error </s> add // dbOpen returns an error if the database can't be opened from the specified // file. It's safe for concurrent use. func (s *StatsCtx) dbOpen() (err error) { </s> remove func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool { </s> add func flushUnitToDB(tx *bbolt.Tx, id uint32, udb *unitDB) bool { </s> remove s, err := createObject(conf) </s> add s, err := New(conf)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// Start makes s process the incoming data. func (s *StatsCtx) Start() {
<mask> return errStop <mask> } <mask> } <mask> <mask> func (s *statsCtx) Start() { <mask> s.initWeb() <mask> go s.periodicFlush() <mask> } <mask> <mask> func checkInterval(days uint32) bool { </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func checkInterval(days uint32) bool { </s> add // checkInterval returns true if days is valid to be used as statistics // retention interval. The valid values are 0, 1, 7, 30 and 90. func checkInterval(days uint32) (ok bool) { </s> remove func (s *statsCtx) loadUnitFromDB(tx *bolt.Tx, id uint32) *unitDB { </s> add func (s *StatsCtx) loadUnitFromDB(tx *bbolt.Tx, id uint32) *unitDB { </s> remove func (s *statsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) { tx := s.beginTxn(false) </s> add func (s *StatsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) { tx := beginTxn(s.database(), false) </s> remove // Delete unit's data from file func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool { </s> add // deleteUnit removes the unit by it's id from the database the tx belongs to. func (s *StatsCtx) deleteUnit(tx *bbolt.Tx, id uint32) bool { </s> remove func (s *statsCtx) dbOpen() bool { var err error </s> add // dbOpen returns an error if the database can't be opened from the specified // file. It's safe for concurrent use. func (s *StatsCtx) dbOpen() (err error) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// checkInterval returns true if days is valid to be used as statistics // retention interval. The valid values are 0, 1, 7, 30 and 90. func checkInterval(days uint32) (ok bool) {
<mask> s.initWeb() <mask> go s.periodicFlush() <mask> } <mask> <mask> func checkInterval(days uint32) bool { <mask> return days == 0 || days == 1 || days == 7 || days == 30 || days == 90 <mask> } <mask> <mask> func (s *statsCtx) dbOpen() bool { <mask> var err error </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func (s *statsCtx) dbOpen() bool { var err error </s> add // dbOpen returns an error if the database can't be opened from the specified // file. It's safe for concurrent use. func (s *StatsCtx) dbOpen() (err error) { </s> remove e.Result >= rLast || </s> add e.Result >= resultLast || </s> remove func (s *statsCtx) Update(e Entry) { if s.conf.limit == 0 { </s> add func (s *StatsCtx) Update(e Entry) { if !s.isEnabled() { </s> remove func (s *statsCtx) Start() { </s> add // Start makes s process the incoming data. func (s *StatsCtx) Start() { </s> remove ok1 := s.flushUnitToDB(tx, u.id, udb) ok2 := s.deleteUnit(tx, id-s.conf.limit) if ok1 || ok2 { </s> add flushOK := flushUnitToDB(tx, u.id, udb) delOK := s.deleteUnit(tx, id-atomic.LoadUint32(&s.limitHours)) if flushOK || delOK {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// dbOpen returns an error if the database can't be opened from the specified // file. It's safe for concurrent use. func (s *StatsCtx) dbOpen() (err error) {
<mask> func checkInterval(days uint32) bool { <mask> return days == 0 || days == 1 || days == 7 || days == 30 || days == 90 <mask> } <mask> <mask> func (s *statsCtx) dbOpen() bool { <mask> var err error <mask> log.Tracef("db.Open...") <mask> s.db, err = bolt.Open(s.conf.Filename, 0o644, nil) <mask> if err != nil { <mask> log.Error("stats: open DB: %s: %s", s.conf.Filename, err) <mask> if err.Error() == "invalid argument" { </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func checkInterval(days uint32) bool { </s> add // checkInterval returns true if days is valid to be used as statistics // retention interval. The valid values are 0, 1, 7, 30 and 90. func checkInterval(days uint32) (ok bool) { </s> remove s.db, err = bolt.Open(s.conf.Filename, 0o644, nil) </s> add s.dbMu.Lock() defer s.dbMu.Unlock() s.db, err = bbolt.Open(s.filename, 0o644, nil) </s> remove log.Error("stats: open DB: %s: %s", s.conf.Filename, err) </s> add log.Error("stats: open DB: %s: %s", s.filename, err) </s> remove e.Result >= rLast || </s> add e.Result >= resultLast || </s> remove func (s *statsCtx) Update(e Entry) { if s.conf.limit == 0 { </s> add func (s *StatsCtx) Update(e Entry) { if !s.isEnabled() {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
s.dbMu.Lock() defer s.dbMu.Unlock() s.db, err = bbolt.Open(s.filename, 0o644, nil)
<mask> <mask> func (s *statsCtx) dbOpen() bool { <mask> var err error <mask> log.Tracef("db.Open...") <mask> s.db, err = bolt.Open(s.conf.Filename, 0o644, nil) <mask> if err != nil { <mask> log.Error("stats: open DB: %s: %s", s.conf.Filename, err) <mask> if err.Error() == "invalid argument" { <mask> log.Error("AdGuard Home cannot be initialized due to an incompatible file system.\nPlease read the explanation here: https://github.com/AdguardTeam/AdGuardHome/wiki/Getting-Started#limitations") <mask> } </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove log.Error("stats: open DB: %s: %s", s.conf.Filename, err) </s> add log.Error("stats: open DB: %s: %s", s.filename, err) </s> remove return false } log.Tracef("db.Open") return true } </s> add </s> remove func (s *statsCtx) dbOpen() bool { var err error </s> add // dbOpen returns an error if the database can't be opened from the specified // file. It's safe for concurrent use. func (s *StatsCtx) dbOpen() (err error) { </s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err) </s> remove func checkInterval(days uint32) bool { </s> add // checkInterval returns true if days is valid to be used as statistics // retention interval. The valid values are 0, 1, 7, 30 and 90. func checkInterval(days uint32) (ok bool) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
log.Error("stats: open DB: %s: %s", s.filename, err)
<mask> var err error <mask> log.Tracef("db.Open...") <mask> s.db, err = bolt.Open(s.conf.Filename, 0o644, nil) <mask> if err != nil { <mask> log.Error("stats: open DB: %s: %s", s.conf.Filename, err) <mask> if err.Error() == "invalid argument" { <mask> log.Error("AdGuard Home cannot be initialized due to an incompatible file system.\nPlease read the explanation here: https://github.com/AdguardTeam/AdGuardHome/wiki/Getting-Started#limitations") <mask> } <mask> return false <mask> } </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove s.db, err = bolt.Open(s.conf.Filename, 0o644, nil) </s> add s.dbMu.Lock() defer s.dbMu.Unlock() s.db, err = bbolt.Open(s.filename, 0o644, nil) </s> remove return false } log.Tracef("db.Open") return true } </s> add </s> remove func (s *statsCtx) dbOpen() bool { var err error </s> add // dbOpen returns an error if the database can't be opened from the specified // file. It's safe for concurrent use. func (s *StatsCtx) dbOpen() (err error) { </s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err) </s> remove log.Error("db.Begin: %s", err) </s> add log.Error("stats: opening a transaction: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
<mask> log.Error("stats: open DB: %s: %s", s.conf.Filename, err) <mask> if err.Error() == "invalid argument" { <mask> log.Error("AdGuard Home cannot be initialized due to an incompatible file system.\nPlease read the explanation here: https://github.com/AdguardTeam/AdGuardHome/wiki/Getting-Started#limitations") <mask> } <mask> return false <mask> } <mask> log.Tracef("db.Open") <mask> return true <mask> } <mask> <mask> // Atomically swap the currently active unit with a new value <mask> // Return old value <mask> func (s *statsCtx) swapUnit(new *unit) (u *unit) { <mask> s.mu.Lock() </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove log.Error("stats: open DB: %s: %s", s.conf.Filename, err) </s> add log.Error("stats: open DB: %s: %s", s.filename, err) </s> remove // Atomically swap the currently active unit with a new value // Return old value func (s *statsCtx) swapUnit(new *unit) (u *unit) { s.mu.Lock() defer s.mu.Unlock() </s> add return err } </s> remove s.db, err = bolt.Open(s.conf.Filename, 0o644, nil) </s> add s.dbMu.Lock() defer s.dbMu.Unlock() s.db, err = bbolt.Open(s.filename, 0o644, nil) </s> remove u = s.current s.current = new </s> add log.Tracef("db.Open") </s> remove func (s *statsCtx) dbOpen() bool { var err error </s> add // dbOpen returns an error if the database can't be opened from the specified // file. It's safe for concurrent use. func (s *StatsCtx) dbOpen() (err error) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
return err }
<mask> log.Tracef("db.Open") <mask> return true <mask> } <mask> <mask> // Atomically swap the currently active unit with a new value <mask> // Return old value <mask> func (s *statsCtx) swapUnit(new *unit) (u *unit) { <mask> s.mu.Lock() <mask> defer s.mu.Unlock() <mask> <mask> u = s.current <mask> s.current = new <mask> <mask> return u </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove return false } log.Tracef("db.Open") return true } </s> add </s> remove u = s.current s.current = new </s> add log.Tracef("db.Open") </s> remove func (s *statsCtx) ongoing() (u *unit) { s.mu.Lock() defer s.mu.Unlock() return s.current } </s> add </s> remove return u </s> add return nil </s> remove s.mu.Lock() defer s.mu.Unlock() </s> add u := s.ongoing() if u == nil { return }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
log.Tracef("db.Open")
<mask> func (s *statsCtx) swapUnit(new *unit) (u *unit) { <mask> s.mu.Lock() <mask> defer s.mu.Unlock() <mask> <mask> u = s.current <mask> s.current = new <mask> <mask> return u <mask> } <mask> <mask> // Get unit ID for the current hour </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove // Atomically swap the currently active unit with a new value // Return old value func (s *statsCtx) swapUnit(new *unit) (u *unit) { s.mu.Lock() defer s.mu.Unlock() </s> add return err } </s> remove return u </s> add return nil </s> remove func (s *statsCtx) ongoing() (u *unit) { s.mu.Lock() defer s.mu.Unlock() return s.current } </s> add </s> remove s.mu.Lock() defer s.mu.Unlock() </s> add u := s.ongoing() if u == nil { return } </s> remove u := s.current </s> add u.mu.Lock() defer u.mu.Unlock()
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
return nil
<mask> <mask> u = s.current <mask> s.current = new <mask> <mask> return u <mask> } <mask> <mask> // Get unit ID for the current hour <mask> func newUnitID() uint32 { <mask> return uint32(time.Now().Unix() / (60 * 60)) </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove // Get unit ID for the current hour func newUnitID() uint32 { return uint32(time.Now().Unix() / (60 * 60)) </s> add // newUnitID is the default UnitIDGenFunc that generates the unique id hourly. func newUnitID() (id uint32) { const secsInHour = int64(time.Hour / time.Second) return uint32(time.Now().Unix() / secsInHour) </s> remove u = s.current s.current = new </s> add log.Tracef("db.Open") </s> remove // Atomically swap the currently active unit with a new value // Return old value func (s *statsCtx) swapUnit(new *unit) (u *unit) { s.mu.Lock() defer s.mu.Unlock() </s> add return err } </s> remove // Initialize a unit func (s *statsCtx) initUnit(u *unit, id uint32) { u.id = id u.nResult = make([]uint64, rLast) u.domains = make(map[string]uint64) u.blockedDomains = make(map[string]uint64) u.clients = make(map[string]uint64) </s> add // newUnit allocates the new *unit. func newUnit(id uint32) (u *unit) { return &unit{ mu: &sync.RWMutex{}, id: id, nResult: make([]uint64, resultLast), domains: make(map[string]uint64), blockedDomains: make(map[string]uint64), clients: make(map[string]uint64), } </s> remove func (s *statsCtx) ongoing() (u *unit) { s.mu.Lock() defer s.mu.Unlock() return s.current } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// newUnitID is the default UnitIDGenFunc that generates the unique id hourly. func newUnitID() (id uint32) { const secsInHour = int64(time.Hour / time.Second) return uint32(time.Now().Unix() / secsInHour)
<mask> <mask> return u <mask> } <mask> <mask> // Get unit ID for the current hour <mask> func newUnitID() uint32 { <mask> return uint32(time.Now().Unix() / (60 * 60)) <mask> } <mask> <mask> // Initialize a unit <mask> func (s *statsCtx) initUnit(u *unit, id uint32) { <mask> u.id = id </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove return u </s> add return nil </s> remove // Initialize a unit func (s *statsCtx) initUnit(u *unit, id uint32) { u.id = id u.nResult = make([]uint64, rLast) u.domains = make(map[string]uint64) u.blockedDomains = make(map[string]uint64) u.clients = make(map[string]uint64) </s> add // newUnit allocates the new *unit. func newUnit(id uint32) (u *unit) { return &unit{ mu: &sync.RWMutex{}, id: id, nResult: make([]uint64, resultLast), domains: make(map[string]uint64), blockedDomains: make(map[string]uint64), clients: make(map[string]uint64), } </s> remove u = s.current s.current = new </s> add log.Tracef("db.Open") </s> remove // Delete unit's data from file func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool { </s> add // deleteUnit removes the unit by it's id from the database the tx belongs to. func (s *StatsCtx) deleteUnit(tx *bbolt.Tx, id uint32) bool { </s> remove db *bolt.DB conf *Config </s> add // filename is the name of database file. filename string // limitHours is the maximum number of hours to collect statistics into the // current unit. limitHours uint32
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// newUnit allocates the new *unit. func newUnit(id uint32) (u *unit) { return &unit{ mu: &sync.RWMutex{}, id: id, nResult: make([]uint64, resultLast), domains: make(map[string]uint64), blockedDomains: make(map[string]uint64), clients: make(map[string]uint64), }
<mask> func newUnitID() uint32 { <mask> return uint32(time.Now().Unix() / (60 * 60)) <mask> } <mask> <mask> // Initialize a unit <mask> func (s *statsCtx) initUnit(u *unit, id uint32) { <mask> u.id = id <mask> u.nResult = make([]uint64, rLast) <mask> u.domains = make(map[string]uint64) <mask> u.blockedDomains = make(map[string]uint64) <mask> u.clients = make(map[string]uint64) <mask> } <mask> <mask> // Open a DB transaction <mask> func (s *statsCtx) beginTxn(wr bool) *bolt.Tx { <mask> db := s.db </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove // Get unit ID for the current hour func newUnitID() uint32 { return uint32(time.Now().Unix() / (60 * 60)) </s> add // newUnitID is the default UnitIDGenFunc that generates the unique id hourly. func newUnitID() (id uint32) { const secsInHour = int64(time.Hour / time.Second) return uint32(time.Now().Unix() / secsInHour) </s> remove // Open a DB transaction func (s *statsCtx) beginTxn(wr bool) *bolt.Tx { db := s.db </s> add // beginTxn opens a new database transaction. If writable is true, the // transaction will be opened for writing, and for reading otherwise. It // returns nil if the transaction can't be created. func beginTxn(db *bbolt.DB, writable bool) (tx *bbolt.Tx) { </s> remove return u </s> add return nil </s> remove u.timeSum = uint64(udb.TimeAvg) * u.nTotal </s> add u.timeSum = uint64(udb.TimeAvg) * udb.NTotal
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// beginTxn opens a new database transaction. If writable is true, the // transaction will be opened for writing, and for reading otherwise. It // returns nil if the transaction can't be created. func beginTxn(db *bbolt.DB, writable bool) (tx *bbolt.Tx) {
<mask> u.blockedDomains = make(map[string]uint64) <mask> u.clients = make(map[string]uint64) <mask> } <mask> <mask> // Open a DB transaction <mask> func (s *statsCtx) beginTxn(wr bool) *bolt.Tx { <mask> db := s.db <mask> if db == nil { <mask> return nil <mask> } <mask> <mask> log.Tracef("db.Begin...") </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove // Initialize a unit func (s *statsCtx) initUnit(u *unit, id uint32) { u.id = id u.nResult = make([]uint64, rLast) u.domains = make(map[string]uint64) u.blockedDomains = make(map[string]uint64) u.clients = make(map[string]uint64) </s> add // newUnit allocates the new *unit. func newUnit(id uint32) (u *unit) { return &unit{ mu: &sync.RWMutex{}, id: id, nResult: make([]uint64, resultLast), domains: make(map[string]uint64), blockedDomains: make(map[string]uint64), clients: make(map[string]uint64), } </s> remove func (s *statsCtx) clear() { tx := s.beginTxn(true) </s> add func (s *StatsCtx) clear() { db := s.database() tx := beginTxn(db, true) </s> remove log.Tracef("db.Begin...") tx, err := db.Begin(wr) </s> add log.Tracef("opening a database transaction") tx, err := db.Begin(writable) </s> remove if s.db != nil { </s> add if db != nil { </s> remove db := s.db s.db = nil </s> add _ = s.swapDatabase(nil)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
log.Tracef("opening a database transaction") tx, err := db.Begin(writable)
<mask> if db == nil { <mask> return nil <mask> } <mask> <mask> log.Tracef("db.Begin...") <mask> tx, err := db.Begin(wr) <mask> if err != nil { <mask> log.Error("db.Begin: %s", err) <mask> return nil <mask> } <mask> log.Tracef("db.Begin") </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove log.Error("db.Begin: %s", err) </s> add log.Error("stats: opening a transaction: %s", err) </s> remove log.Tracef("db.Begin") </s> add log.Tracef("transaction has been opened") </s> remove func (s *statsCtx) commitTxn(tx *bolt.Tx) { </s> add // commitTxn applies the changes made in tx to the database. func (s *StatsCtx) commitTxn(tx *bbolt.Tx) { </s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err) </s> remove if !s.dbOpen() { return nil, fmt.Errorf("open database") </s> add if err = s.dbOpen(); err != nil { return nil, fmt.Errorf("opening database: %w", err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
log.Error("stats: opening a transaction: %s", err)
<mask> <mask> log.Tracef("db.Begin...") <mask> tx, err := db.Begin(wr) <mask> if err != nil { <mask> log.Error("db.Begin: %s", err) <mask> return nil <mask> } <mask> log.Tracef("db.Begin") <mask> return tx <mask> } </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove log.Tracef("db.Begin...") tx, err := db.Begin(wr) </s> add log.Tracef("opening a database transaction") tx, err := db.Begin(writable) </s> remove log.Tracef("db.Begin") </s> add log.Tracef("transaction has been opened") </s> remove func (s *statsCtx) commitTxn(tx *bolt.Tx) { </s> add // commitTxn applies the changes made in tx to the database. func (s *StatsCtx) commitTxn(tx *bbolt.Tx) { </s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err) </s> remove if !s.dbOpen() { return nil, fmt.Errorf("open database") </s> add if err = s.dbOpen(); err != nil { return nil, fmt.Errorf("opening database: %w", err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
log.Tracef("transaction has been opened")
<mask> if err != nil { <mask> log.Error("db.Begin: %s", err) <mask> return nil <mask> } <mask> log.Tracef("db.Begin") <mask> return tx <mask> } <mask> <mask> func (s *statsCtx) commitTxn(tx *bolt.Tx) { <mask> err := tx.Commit() </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func (s *statsCtx) commitTxn(tx *bolt.Tx) { </s> add // commitTxn applies the changes made in tx to the database. func (s *StatsCtx) commitTxn(tx *bbolt.Tx) { </s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err) </s> remove log.Error("db.Begin: %s", err) </s> add log.Error("stats: opening a transaction: %s", err) </s> remove log.Tracef("db.Begin...") tx, err := db.Begin(wr) </s> add log.Tracef("opening a database transaction") tx, err := db.Begin(writable) </s> remove func (s *statsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// commitTxn applies the changes made in tx to the database. func (s *StatsCtx) commitTxn(tx *bbolt.Tx) {
<mask> log.Tracef("db.Begin") <mask> return tx <mask> } <mask> <mask> func (s *statsCtx) commitTxn(tx *bolt.Tx) { <mask> err := tx.Commit() <mask> if err != nil { <mask> log.Debug("tx.Commit: %s", err) <mask> return <mask> } </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove log.Tracef("db.Begin") </s> add log.Tracef("transaction has been opened") </s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err) </s> remove log.Error("db.Begin: %s", err) </s> add log.Error("stats: opening a transaction: %s", err) </s> remove log.Tracef("db.Begin...") tx, err := db.Begin(wr) </s> add log.Tracef("opening a database transaction") tx, err := db.Begin(writable) </s> remove func (s *statsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
log.Error("stats: committing a transaction: %s", err)
<mask> <mask> func (s *statsCtx) commitTxn(tx *bolt.Tx) { <mask> err := tx.Commit() <mask> if err != nil { <mask> log.Debug("tx.Commit: %s", err) <mask> return <mask> } <mask> log.Tracef("tx.Commit") <mask> } <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func (s *statsCtx) commitTxn(tx *bolt.Tx) { </s> add // commitTxn applies the changes made in tx to the database. func (s *StatsCtx) commitTxn(tx *bbolt.Tx) { </s> remove log.Tracef("db.Begin") </s> add log.Tracef("transaction has been opened") </s> remove log.Tracef("tx.Commit") </s> add log.Tracef("transaction has been committed") </s> remove log.Error("db.Begin: %s", err) </s> add log.Error("stats: opening a transaction: %s", err) </s> remove func (s *statsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
log.Tracef("transaction has been committed")
<mask> if err != nil { <mask> log.Debug("tx.Commit: %s", err) <mask> return <mask> } <mask> log.Tracef("tx.Commit") <mask> } <mask> <mask> // bucketNameLen is the length of a bucket, a 64-bit unsigned integer. <mask> // <mask> // TODO(a.garipov): Find out why a 64-bit integer is used when IDs seem to </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err) </s> remove func (s *statsCtx) commitTxn(tx *bolt.Tx) { </s> add // commitTxn applies the changes made in tx to the database. func (s *StatsCtx) commitTxn(tx *bbolt.Tx) { </s> remove log.Error("db.Begin: %s", err) </s> add log.Error("stats: opening a transaction: %s", err) </s> remove name = make([]byte, bucketNameLen) binary.BigEndian.PutUint64(name, uint64(id)) </s> add n := [bucketNameLen]byte{} binary.BigEndian.PutUint64(n[:], uint64(id)) </s> remove func (s *statsCtx) ongoing() (u *unit) { s.mu.Lock() defer s.mu.Unlock() return s.current } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
n := [bucketNameLen]byte{} binary.BigEndian.PutUint64(n[:], uint64(id))
<mask> const bucketNameLen = 8 <mask> <mask> // idToUnitName converts a numerical ID into a database unit name. <mask> func idToUnitName(id uint32) (name []byte) { <mask> name = make([]byte, bucketNameLen) <mask> binary.BigEndian.PutUint64(name, uint64(id)) <mask> <mask> return name <mask> } <mask> <mask> // unitNameToID converts a database unit name into a numerical ID. ok is false </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove return name </s> add return n[:] </s> remove db *bolt.DB conf *Config </s> add // filename is the name of database file. filename string // limitHours is the maximum number of hours to collect statistics into the // current unit. limitHours uint32 </s> remove // Get unit ID for the current hour func newUnitID() uint32 { return uint32(time.Now().Unix() / (60 * 60)) </s> add // newUnitID is the default UnitIDGenFunc that generates the unique id hourly. func newUnitID() (id uint32) { const secsInHour = int64(time.Hour / time.Second) return uint32(time.Now().Unix() / secsInHour) </s> remove // Config - module configuration </s> add // Config is the configuration structure for the statistics collecting. </s> remove log.Tracef("tx.Commit") </s> add log.Tracef("transaction has been committed")
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
return n[:]
<mask> func idToUnitName(id uint32) (name []byte) { <mask> name = make([]byte, bucketNameLen) <mask> binary.BigEndian.PutUint64(name, uint64(id)) <mask> <mask> return name <mask> } <mask> <mask> // unitNameToID converts a database unit name into a numerical ID. ok is false <mask> // if name is not a valid database unit name. <mask> func unitNameToID(name []byte) (id uint32, ok bool) { </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove name = make([]byte, bucketNameLen) binary.BigEndian.PutUint64(name, uint64(id)) </s> add n := [bucketNameLen]byte{} binary.BigEndian.PutUint64(n[:], uint64(id)) </s> remove db *bolt.DB conf *Config </s> add // filename is the name of database file. filename string // limitHours is the maximum number of hours to collect statistics into the // current unit. limitHours uint32 </s> remove // Config - module configuration </s> add // Config is the configuration structure for the statistics collecting. </s> remove // Get unit ID for the current hour func newUnitID() uint32 { return uint32(time.Now().Unix() / (60 * 60)) </s> add // newUnitID is the default UnitIDGenFunc that generates the unique id hourly. func newUnitID() (id uint32) { const secsInHour = int64(time.Hour / time.Second) return uint32(time.Now().Unix() / secsInHour) </s> remove Filename string // database file name LimitDays uint32 // time limit (in days) UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used. </s> add // UnitID is the function to generate the identifier for current unit. If // nil, the default function is used, see newUnitID. UnitID UnitIDGenFunc
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
<mask> <mask> return uint32(binary.BigEndian.Uint64(name)), true <mask> } <mask> <mask> func (s *statsCtx) ongoing() (u *unit) { <mask> s.mu.Lock() <mask> defer s.mu.Unlock() <mask> <mask> return s.current <mask> } <mask> <mask> // Flush the current unit to DB and delete an old unit when a new hour is started <mask> // If a unit must be flushed: <mask> // . lock DB <mask> // . atomically set a new empty unit as the current one and get the old unit <mask> // This is important to do it inside DB lock, so the reader won't get inconsistent results. </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func (s *statsCtx) periodicFlush() { for { ptr := s.ongoing() if ptr == nil { break } id := s.conf.UnitID() if ptr.id == id || s.conf.limit == 0 { </s> add func (s *StatsCtx) periodicFlush() { for ptr := s.ongoing(); ptr != nil; ptr = s.ongoing() { id := s.unitIDGen() // Access the unit's ID with atomic to avoid locking the whole unit. if !s.isEnabled() || atomic.LoadUint32(&ptr.id) == id { </s> remove // Atomically swap the currently active unit with a new value // Return old value func (s *statsCtx) swapUnit(new *unit) (u *unit) { s.mu.Lock() defer s.mu.Unlock() </s> add return err } </s> remove u = s.current s.current = new </s> add log.Tracef("db.Open") </s> remove return false } log.Tracef("db.Open") return true } </s> add </s> remove Filename string // database file name LimitDays uint32 // time limit (in days) UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used. </s> add // UnitID is the function to generate the identifier for current unit. If // nil, the default function is used, see newUnitID. UnitID UnitIDGenFunc
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
func (s *StatsCtx) periodicFlush() { for ptr := s.ongoing(); ptr != nil; ptr = s.ongoing() { id := s.unitIDGen() // Access the unit's ID with atomic to avoid locking the whole unit. if !s.isEnabled() || atomic.LoadUint32(&ptr.id) == id {
<mask> // This is important to do it inside DB lock, so the reader won't get inconsistent results. <mask> // . write the unit to DB <mask> // . remove the stale unit from DB <mask> // . unlock DB <mask> func (s *statsCtx) periodicFlush() { <mask> for { <mask> ptr := s.ongoing() <mask> if ptr == nil { <mask> break <mask> } <mask> <mask> id := s.conf.UnitID() <mask> if ptr.id == id || s.conf.limit == 0 { <mask> time.Sleep(time.Second) <mask> <mask> continue <mask> } <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func (s *statsCtx) ongoing() (u *unit) { s.mu.Lock() defer s.mu.Unlock() return s.current } </s> add </s> remove // Initialize a unit func (s *statsCtx) initUnit(u *unit, id uint32) { u.id = id u.nResult = make([]uint64, rLast) u.domains = make(map[string]uint64) u.blockedDomains = make(map[string]uint64) u.clients = make(map[string]uint64) </s> add // newUnit allocates the new *unit. func newUnit(id uint32) (u *unit) { return &unit{ mu: &sync.RWMutex{}, id: id, nResult: make([]uint64, resultLast), domains: make(map[string]uint64), blockedDomains: make(map[string]uint64), clients: make(map[string]uint64), } </s> remove // Open a DB transaction func (s *statsCtx) beginTxn(wr bool) *bolt.Tx { db := s.db </s> add // beginTxn opens a new database transaction. If writable is true, the // transaction will be opened for writing, and for reading otherwise. It // returns nil if the transaction can't be created. func beginTxn(db *bbolt.DB, writable bool) (tx *bbolt.Tx) { </s> remove // Delete unit's data from file func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool { </s> add // deleteUnit removes the unit by it's id from the database the tx belongs to. func (s *StatsCtx) deleteUnit(tx *bbolt.Tx, id uint32) bool { </s> remove func (s *statsCtx) dbOpen() bool { var err error </s> add // dbOpen returns an error if the database can't be opened from the specified // file. It's safe for concurrent use. func (s *StatsCtx) dbOpen() (err error) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
tx := beginTxn(s.database(), true)
<mask> <mask> continue <mask> } <mask> <mask> tx := s.beginTxn(true) <mask> <mask> nu := unit{} <mask> s.initUnit(&nu, id) <mask> u := s.swapUnit(&nu) <mask> udb := serialize(u) </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove nu := unit{} s.initUnit(&nu, id) u := s.swapUnit(&nu) udb := serialize(u) </s> add nu := newUnit(id) u := s.swapCurrent(nu) udb := u.serialize() </s> remove func (s *statsCtx) Close() { u := s.swapUnit(nil) udb := serialize(u) tx := s.beginTxn(true) if tx != nil { if s.flushUnitToDB(tx, u.id, udb) { </s> add func (s *StatsCtx) Close() { u := s.swapCurrent(nil) db := s.database() if tx := beginTxn(db, true); tx != nil { udb := u.serialize() if flushUnitToDB(tx, u.id, udb) { </s> remove u := unit{} s.initUnit(&u, id) if udb != nil { deserialize(&u, udb) } s.current = &u </s> add u := newUnit(id) // This use of deserialize is safe since the accessed unit has just been // created. u.deserialize(udb) s.curr = u </s> remove id := s.conf.UnitID() tx := s.beginTxn(true) </s> add id := s.unitIDGen() tx := beginTxn(s.db, true) </s> remove func (s *statsCtx) clear() { tx := s.beginTxn(true) </s> add func (s *StatsCtx) clear() { db := s.database() tx := beginTxn(db, true)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
nu := newUnit(id) u := s.swapCurrent(nu) udb := u.serialize()
<mask> } <mask> <mask> tx := s.beginTxn(true) <mask> <mask> nu := unit{} <mask> s.initUnit(&nu, id) <mask> u := s.swapUnit(&nu) <mask> udb := serialize(u) <mask> <mask> if tx == nil { <mask> continue <mask> } <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove tx := s.beginTxn(true) </s> add tx := beginTxn(s.database(), true) </s> remove func (s *statsCtx) Close() { u := s.swapUnit(nil) udb := serialize(u) tx := s.beginTxn(true) if tx != nil { if s.flushUnitToDB(tx, u.id, udb) { </s> add func (s *StatsCtx) Close() { u := s.swapCurrent(nil) db := s.database() if tx := beginTxn(db, true); tx != nil { udb := u.serialize() if flushUnitToDB(tx, u.id, udb) { </s> remove id := s.conf.UnitID() tx := s.beginTxn(true) </s> add id := s.unitIDGen() tx := beginTxn(s.db, true) </s> remove func (s *statsCtx) clear() { tx := s.beginTxn(true) </s> add func (s *StatsCtx) clear() { db := s.database() tx := beginTxn(db, true) </s> remove u := unit{} s.initUnit(&u, id) if udb != nil { deserialize(&u, udb) } s.current = &u </s> add u := newUnit(id) // This use of deserialize is safe since the accessed unit has just been // created. u.deserialize(udb) s.curr = u
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
flushOK := flushUnitToDB(tx, u.id, udb) delOK := s.deleteUnit(tx, id-atomic.LoadUint32(&s.limitHours)) if flushOK || delOK {
<mask> if tx == nil { <mask> continue <mask> } <mask> <mask> ok1 := s.flushUnitToDB(tx, u.id, udb) <mask> ok2 := s.deleteUnit(tx, id-s.conf.limit) <mask> if ok1 || ok2 { <mask> s.commitTxn(tx) <mask> } else { <mask> _ = tx.Rollback() <mask> } <mask> } </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func (s *statsCtx) Close() { u := s.swapUnit(nil) udb := serialize(u) tx := s.beginTxn(true) if tx != nil { if s.flushUnitToDB(tx, u.id, udb) { </s> add func (s *StatsCtx) Close() { u := s.swapCurrent(nil) db := s.database() if tx := beginTxn(db, true); tx != nil { udb := u.serialize() if flushUnitToDB(tx, u.id, udb) { </s> remove func (s *statsCtx) clear() { tx := s.beginTxn(true) </s> add func (s *StatsCtx) clear() { db := s.database() tx := beginTxn(db, true) </s> remove if s.db != nil { </s> add if db != nil { </s> remove nu := unit{} s.initUnit(&nu, id) u := s.swapUnit(&nu) udb := serialize(u) </s> add nu := newUnit(id) u := s.swapCurrent(nu) udb := u.serialize() </s> remove units, _ := s.loadUnits(s.conf.limit) </s> add units, _ := s.loadUnits(atomic.LoadUint32(&s.limitHours))
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// deleteUnit removes the unit by it's id from the database the tx belongs to. func (s *StatsCtx) deleteUnit(tx *bbolt.Tx, id uint32) bool {
<mask> <mask> log.Tracef("periodicFlush() exited") <mask> } <mask> <mask> // Delete unit's data from file <mask> func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool { <mask> err := tx.DeleteBucket(idToUnitName(id)) <mask> if err != nil { <mask> log.Tracef("stats: bolt DeleteBucket: %s", err) <mask> <mask> return false </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool { </s> add func flushUnitToDB(tx *bbolt.Tx, id uint32, udb *unitDB) bool { </s> remove func (s *statsCtx) loadUnitFromDB(tx *bolt.Tx, id uint32) *unitDB { </s> add func (s *StatsCtx) loadUnitFromDB(tx *bbolt.Tx, id uint32) *unitDB { </s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err) </s> remove func (s *statsCtx) dbOpen() bool { var err error </s> add // dbOpen returns an error if the database can't be opened from the specified // file. It's safe for concurrent use. func (s *StatsCtx) dbOpen() (err error) { </s> remove log.Error("stats: open DB: %s: %s", s.conf.Filename, err) </s> add log.Error("stats: open DB: %s: %s", s.filename, err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
a = append(a, countPair{Name: k, Count: v})
<mask> <mask> func convertMapToSlice(m map[string]uint64, max int) []countPair { <mask> a := []countPair{} <mask> for k, v := range m { <mask> pair := countPair{} <mask> pair.Name = k <mask> pair.Count = v <mask> a = append(a, pair) <mask> } <mask> less := func(i, j int) bool { <mask> return a[j].Count < a[i].Count <mask> } <mask> sort.Slice(a, less) </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove ent := map[string]uint64{} ent[it.Name] = it.Count m = append(m, ent) </s> add m = append(m, map[string]uint64{it.Name: it.Count}) </s> remove func convertTopSlice(a []countPair) []map[string]uint64 { m := []map[string]uint64{} </s> add func convertTopSlice(a []countPair) (m []map[string]uint64) { m = make([]map[string]uint64, 0, len(a)) </s> remove func (s *statsCtx) setLimit(limitDays int) { s.conf.limit = uint32(limitDays) * 24 </s> add func (s *StatsCtx) setLimit(limitDays int) { atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) </s> remove for _, it := range pg(u) { m[it.Name] += it.Count </s> add for _, cp := range pg(u) { m[cp.Name] += cp.Count </s> remove // topsCollector collects statistics about highest values fro the given *unitDB </s> add // topsCollector collects statistics about highest values from the given *unitDB
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// serialize converts u to the *unitDB. It's safe for concurrent use. func (u *unit) serialize() (udb *unitDB) { u.mu.RLock() defer u.mu.RUnlock()
<mask> } <mask> return m <mask> } <mask> <mask> func serialize(u *unit) *unitDB { <mask> udb := unitDB{} <mask> udb.NTotal = u.nTotal <mask> <mask> udb.NResult = append(udb.NResult, u.nResult...) <mask> <mask> if u.nTotal != 0 { <mask> udb.TimeAvg = uint32(u.timeSum / u.nTotal) <mask> } <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove udb.TimeAvg = uint32(u.timeSum / u.nTotal) </s> add timeAvg = uint32(u.timeSum / u.nTotal) </s> remove udb.Domains = convertMapToSlice(u.domains, maxDomains) udb.BlockedDomains = convertMapToSlice(u.blockedDomains, maxDomains) udb.Clients = convertMapToSlice(u.clients, maxClients) return &udb </s> add return &unitDB{ NTotal: u.nTotal, NResult: append([]uint64{}, u.nResult...), Domains: convertMapToSlice(u.domains, maxDomains), BlockedDomains: convertMapToSlice(u.blockedDomains, maxDomains), Clients: convertMapToSlice(u.clients, maxClients), TimeAvg: timeAvg, } </s> remove func deserialize(u *unit, udb *unitDB) { u.nTotal = udb.NTotal n := len(udb.NResult) if n < len(u.nResult) { n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult)) } for i := 1; i < n; i++ { u.nResult[i] = udb.NResult[i] </s> add // deserealize assigns the appropriate values from udb to u. u must not be nil. // It's safe for concurrent use. func (u *unit) deserialize(udb *unitDB) { if udb == nil { return </s> remove u.timeSum = uint64(udb.TimeAvg) * u.nTotal </s> add u.timeSum = uint64(udb.TimeAvg) * udb.NTotal
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
var timeAvg uint32 = 0
<mask> defer u.mu.RUnlock() <mask> <mask> if u.nTotal != 0 { <mask> timeAvg = uint32(u.timeSum / u.nTotal) <mask> } <mask> <mask> return &unitDB{ <mask> NTotal: u.nTotal, </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove udb.Domains = convertMapToSlice(u.domains, maxDomains) udb.BlockedDomains = convertMapToSlice(u.blockedDomains, maxDomains) udb.Clients = convertMapToSlice(u.clients, maxClients) return &udb </s> add return &unitDB{ NTotal: u.nTotal, NResult: append([]uint64{}, u.nResult...), Domains: convertMapToSlice(u.domains, maxDomains), BlockedDomains: convertMapToSlice(u.blockedDomains, maxDomains), Clients: convertMapToSlice(u.clients, maxClients), TimeAvg: timeAvg, } </s> remove udb.TimeAvg = uint32(u.timeSum / u.nTotal) </s> add timeAvg = uint32(u.timeSum / u.nTotal) </s> remove func serialize(u *unit) *unitDB { udb := unitDB{} udb.NTotal = u.nTotal udb.NResult = append(udb.NResult, u.nResult...) </s> add // serialize converts u to the *unitDB. It's safe for concurrent use. func (u *unit) serialize() (udb *unitDB) { u.mu.RLock() defer u.mu.RUnlock() </s> remove log.Debug("stats: set limit: %d", limitDays) </s> add log.Debug("stats: set limit: %d days", limitDays)
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
timeAvg = uint32(u.timeSum / u.nTotal)
<mask> <mask> udb.NResult = append(udb.NResult, u.nResult...) <mask> <mask> if u.nTotal != 0 { <mask> udb.TimeAvg = uint32(u.timeSum / u.nTotal) <mask> } <mask> <mask> udb.Domains = convertMapToSlice(u.domains, maxDomains) <mask> udb.BlockedDomains = convertMapToSlice(u.blockedDomains, maxDomains) <mask> udb.Clients = convertMapToSlice(u.clients, maxClients) </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove udb.Domains = convertMapToSlice(u.domains, maxDomains) udb.BlockedDomains = convertMapToSlice(u.blockedDomains, maxDomains) udb.Clients = convertMapToSlice(u.clients, maxClients) return &udb </s> add return &unitDB{ NTotal: u.nTotal, NResult: append([]uint64{}, u.nResult...), Domains: convertMapToSlice(u.domains, maxDomains), BlockedDomains: convertMapToSlice(u.blockedDomains, maxDomains), Clients: convertMapToSlice(u.clients, maxClients), TimeAvg: timeAvg, } </s> remove func serialize(u *unit) *unitDB { udb := unitDB{} udb.NTotal = u.nTotal udb.NResult = append(udb.NResult, u.nResult...) </s> add // serialize converts u to the *unitDB. It's safe for concurrent use. func (u *unit) serialize() (udb *unitDB) { u.mu.RLock() defer u.mu.RUnlock() </s> remove log.Debug("stats: set limit: %d", limitDays) </s> add log.Debug("stats: set limit: %d days", limitDays) </s> remove func (s *statsCtx) WriteDiskConfig(dc *DiskConfig) { dc.Interval = s.conf.limit / 24 </s> add func (s *StatsCtx) WriteDiskConfig(dc *DiskConfig) { dc.Interval = atomic.LoadUint32(&s.limitHours) / 24
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
return &unitDB{ NTotal: u.nTotal, NResult: append([]uint64{}, u.nResult...), Domains: convertMapToSlice(u.domains, maxDomains), BlockedDomains: convertMapToSlice(u.blockedDomains, maxDomains), Clients: convertMapToSlice(u.clients, maxClients), TimeAvg: timeAvg, }
<mask> if u.nTotal != 0 { <mask> udb.TimeAvg = uint32(u.timeSum / u.nTotal) <mask> } <mask> <mask> udb.Domains = convertMapToSlice(u.domains, maxDomains) <mask> udb.BlockedDomains = convertMapToSlice(u.blockedDomains, maxDomains) <mask> udb.Clients = convertMapToSlice(u.clients, maxClients) <mask> <mask> return &udb <mask> } <mask> <mask> func deserialize(u *unit, udb *unitDB) { <mask> u.nTotal = udb.NTotal <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove udb.TimeAvg = uint32(u.timeSum / u.nTotal) </s> add timeAvg = uint32(u.timeSum / u.nTotal) </s> remove func serialize(u *unit) *unitDB { udb := unitDB{} udb.NTotal = u.nTotal udb.NResult = append(udb.NResult, u.nResult...) </s> add // serialize converts u to the *unitDB. It's safe for concurrent use. func (u *unit) serialize() (udb *unitDB) { u.mu.RLock() defer u.mu.RUnlock() </s> remove func deserialize(u *unit, udb *unitDB) { u.nTotal = udb.NTotal n := len(udb.NResult) if n < len(u.nResult) { n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult)) } for i := 1; i < n; i++ { u.nResult[i] = udb.NResult[i] </s> add // deserealize assigns the appropriate values from udb to u. u must not be nil. // It's safe for concurrent use. func (u *unit) deserialize(udb *unitDB) { if udb == nil { return </s> remove u.timeSum = uint64(udb.TimeAvg) * u.nTotal </s> add u.timeSum = uint64(udb.TimeAvg) * udb.NTotal
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// deserealize assigns the appropriate values from udb to u. u must not be nil. // It's safe for concurrent use. func (u *unit) deserialize(udb *unitDB) { if udb == nil { return
<mask> <mask> return &udb <mask> } <mask> <mask> func deserialize(u *unit, udb *unitDB) { <mask> u.nTotal = udb.NTotal <mask> <mask> n := len(udb.NResult) <mask> if n < len(u.nResult) { <mask> n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult)) <mask> } <mask> for i := 1; i < n; i++ { <mask> u.nResult[i] = udb.NResult[i] <mask> } <mask> <mask> u.domains = convertSliceToMap(udb.Domains) <mask> u.blockedDomains = convertSliceToMap(udb.BlockedDomains) <mask> u.clients = convertSliceToMap(udb.Clients) </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove u.timeSum = uint64(udb.TimeAvg) * u.nTotal </s> add u.timeSum = uint64(udb.TimeAvg) * udb.NTotal </s> remove udb.Domains = convertMapToSlice(u.domains, maxDomains) udb.BlockedDomains = convertMapToSlice(u.blockedDomains, maxDomains) udb.Clients = convertMapToSlice(u.clients, maxClients) return &udb </s> add return &unitDB{ NTotal: u.nTotal, NResult: append([]uint64{}, u.nResult...), Domains: convertMapToSlice(u.domains, maxDomains), BlockedDomains: convertMapToSlice(u.blockedDomains, maxDomains), Clients: convertMapToSlice(u.clients, maxClients), TimeAvg: timeAvg, } </s> remove u.NResult = make([]uint64, rLast) </s> add u.NResult = make([]uint64, resultLast) </s> remove curID := cur.id </s> add var curID uint32 if cur != nil { curID = atomic.LoadUint32(&cur.id) } else { curID = s.unitIDGen() }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
u.mu.Lock() defer u.mu.Unlock() u.nTotal = udb.NTotal u.nResult = make([]uint64, resultLast) copy(u.nResult, udb.NResult)
<mask> } <mask> <mask> u.domains = convertSliceToMap(udb.Domains) <mask> u.blockedDomains = convertSliceToMap(udb.BlockedDomains) <mask> u.clients = convertSliceToMap(udb.Clients) <mask> u.timeSum = uint64(udb.TimeAvg) * udb.NTotal <mask> } <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove u.timeSum = uint64(udb.TimeAvg) * u.nTotal </s> add u.timeSum = uint64(udb.TimeAvg) * udb.NTotal </s> remove func deserialize(u *unit, udb *unitDB) { u.nTotal = udb.NTotal n := len(udb.NResult) if n < len(u.nResult) { n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult)) } for i := 1; i < n; i++ { u.nResult[i] = udb.NResult[i] </s> add // deserealize assigns the appropriate values from udb to u. u must not be nil. // It's safe for concurrent use. func (u *unit) deserialize(udb *unitDB) { if udb == nil { return </s> remove func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool { </s> add func flushUnitToDB(tx *bbolt.Tx, id uint32, udb *unitDB) bool { </s> remove // Initialize a unit func (s *statsCtx) initUnit(u *unit, id uint32) { u.id = id u.nResult = make([]uint64, rLast) u.domains = make(map[string]uint64) u.blockedDomains = make(map[string]uint64) u.clients = make(map[string]uint64) </s> add // newUnit allocates the new *unit. func newUnit(id uint32) (u *unit) { return &unit{ mu: &sync.RWMutex{}, id: id, nResult: make([]uint64, resultLast), domains: make(map[string]uint64), blockedDomains: make(map[string]uint64), clients: make(map[string]uint64), } </s> remove if !checkInterval(conf.LimitDays) { conf.LimitDays = 1 </s> add if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) { s.limitHours = 24
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
u.timeSum = uint64(udb.TimeAvg) * udb.NTotal
<mask> <mask> u.domains = convertSliceToMap(udb.Domains) <mask> u.blockedDomains = convertSliceToMap(udb.BlockedDomains) <mask> u.clients = convertSliceToMap(udb.Clients) <mask> u.timeSum = uint64(udb.TimeAvg) * u.nTotal <mask> } <mask> <mask> func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool { <mask> log.Tracef("Flushing unit %d", id) <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool { </s> add func flushUnitToDB(tx *bbolt.Tx, id uint32, udb *unitDB) bool { </s> remove func deserialize(u *unit, udb *unitDB) { u.nTotal = udb.NTotal n := len(udb.NResult) if n < len(u.nResult) { n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult)) } for i := 1; i < n; i++ { u.nResult[i] = udb.NResult[i] </s> add // deserealize assigns the appropriate values from udb to u. u must not be nil. // It's safe for concurrent use. func (u *unit) deserialize(udb *unitDB) { if udb == nil { return </s> remove // Initialize a unit func (s *statsCtx) initUnit(u *unit, id uint32) { u.id = id u.nResult = make([]uint64, rLast) u.domains = make(map[string]uint64) u.blockedDomains = make(map[string]uint64) u.clients = make(map[string]uint64) </s> add // newUnit allocates the new *unit. func newUnit(id uint32) (u *unit) { return &unit{ mu: &sync.RWMutex{}, id: id, nResult: make([]uint64, resultLast), domains: make(map[string]uint64), blockedDomains: make(map[string]uint64), clients: make(map[string]uint64), } </s> remove // Delete unit's data from file func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool { </s> add // deleteUnit removes the unit by it's id from the database the tx belongs to. func (s *StatsCtx) deleteUnit(tx *bbolt.Tx, id uint32) bool {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
func flushUnitToDB(tx *bbolt.Tx, id uint32, udb *unitDB) bool {
<mask> u.clients = convertSliceToMap(udb.Clients) <mask> u.timeSum = uint64(udb.TimeAvg) * u.nTotal <mask> } <mask> <mask> func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool { <mask> log.Tracef("Flushing unit %d", id) <mask> <mask> bkt, err := tx.CreateBucketIfNotExists(idToUnitName(id)) <mask> if err != nil { <mask> log.Error("tx.CreateBucketIfNotExists: %s", err) </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove u.timeSum = uint64(udb.TimeAvg) * u.nTotal </s> add u.timeSum = uint64(udb.TimeAvg) * udb.NTotal </s> remove // Delete unit's data from file func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool { </s> add // deleteUnit removes the unit by it's id from the database the tx belongs to. func (s *StatsCtx) deleteUnit(tx *bbolt.Tx, id uint32) bool { </s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err) </s> remove func deserialize(u *unit, udb *unitDB) { u.nTotal = udb.NTotal n := len(udb.NResult) if n < len(u.nResult) { n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult)) } for i := 1; i < n; i++ { u.nResult[i] = udb.NResult[i] </s> add // deserealize assigns the appropriate values from udb to u. u must not be nil. // It's safe for concurrent use. func (u *unit) deserialize(udb *unitDB) { if udb == nil { return
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
func (s *StatsCtx) loadUnitFromDB(tx *bbolt.Tx, id uint32) *unitDB {
<mask> <mask> return true <mask> } <mask> <mask> func (s *statsCtx) loadUnitFromDB(tx *bolt.Tx, id uint32) *unitDB { <mask> bkt := tx.Bucket(idToUnitName(id)) <mask> if bkt == nil { <mask> return nil <mask> } <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove // Delete unit's data from file func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool { </s> add // deleteUnit removes the unit by it's id from the database the tx belongs to. func (s *StatsCtx) deleteUnit(tx *bbolt.Tx, id uint32) bool { </s> remove func (s *statsCtx) GetTopClientsIP(maxCount uint) []net.IP { if s.conf.limit == 0 { </s> add func (s *StatsCtx) GetTopClientsIP(maxCount uint) []net.IP { if !s.isEnabled() { </s> remove func (s *statsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) { tx := s.beginTxn(false) </s> add func (s *StatsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) { tx := beginTxn(s.database(), false) </s> remove if !s.dbOpen() { return nil, fmt.Errorf("open database") </s> add if err = s.dbOpen(); err != nil { return nil, fmt.Errorf("opening database: %w", err) </s> remove func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool { </s> add func flushUnitToDB(tx *bbolt.Tx, id uint32, udb *unitDB) bool {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
func convertTopSlice(a []countPair) (m []map[string]uint64) { m = make([]map[string]uint64, 0, len(a))
<mask> <mask> return &udb <mask> } <mask> <mask> func convertTopSlice(a []countPair) []map[string]uint64 { <mask> m := []map[string]uint64{} <mask> for _, it := range a { <mask> ent := map[string]uint64{} <mask> ent[it.Name] = it.Count <mask> m = append(m, ent) <mask> } </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove ent := map[string]uint64{} ent[it.Name] = it.Count m = append(m, ent) </s> add m = append(m, map[string]uint64{it.Name: it.Count}) </s> remove for _, it := range pg(u) { m[it.Name] += it.Count </s> add for _, cp := range pg(u) { m[cp.Name] += cp.Count </s> remove // topsCollector collects statistics about highest values fro the given *unitDB </s> add // topsCollector collects statistics about highest values from the given *unitDB </s> remove pair := countPair{} pair.Name = k pair.Count = v a = append(a, pair) </s> add a = append(a, countPair{Name: k, Count: v}) </s> remove NResult: make([]uint64, rLast), </s> add NResult: make([]uint64, resultLast),
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
m = append(m, map[string]uint64{it.Name: it.Count})
<mask> <mask> func convertTopSlice(a []countPair) []map[string]uint64 { <mask> m := []map[string]uint64{} <mask> for _, it := range a { <mask> ent := map[string]uint64{} <mask> ent[it.Name] = it.Count <mask> m = append(m, ent) <mask> } <mask> return m <mask> } <mask> <mask> func (s *statsCtx) setLimit(limitDays int) { </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func convertTopSlice(a []countPair) []map[string]uint64 { m := []map[string]uint64{} </s> add func convertTopSlice(a []countPair) (m []map[string]uint64) { m = make([]map[string]uint64, 0, len(a)) </s> remove for _, it := range pg(u) { m[it.Name] += it.Count </s> add for _, cp := range pg(u) { m[cp.Name] += cp.Count </s> remove // topsCollector collects statistics about highest values fro the given *unitDB </s> add // topsCollector collects statistics about highest values from the given *unitDB </s> remove func (s *statsCtx) setLimit(limitDays int) { s.conf.limit = uint32(limitDays) * 24 </s> add func (s *StatsCtx) setLimit(limitDays int) { atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) </s> remove pair := countPair{} pair.Name = k pair.Count = v a = append(a, pair) </s> add a = append(a, countPair{Name: k, Count: v})
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
func (s *StatsCtx) setLimit(limitDays int) { atomic.StoreUint32(&s.limitHours, uint32(24*limitDays))
<mask> } <mask> return m <mask> } <mask> <mask> func (s *statsCtx) setLimit(limitDays int) { <mask> s.conf.limit = uint32(limitDays) * 24 <mask> if limitDays == 0 { <mask> s.clear() <mask> } <mask> <mask> log.Debug("stats: set limit: %d", limitDays) </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove log.Debug("stats: set limit: %d", limitDays) </s> add log.Debug("stats: set limit: %d days", limitDays) </s> remove func (s *statsCtx) WriteDiskConfig(dc *DiskConfig) { dc.Interval = s.conf.limit / 24 </s> add func (s *StatsCtx) WriteDiskConfig(dc *DiskConfig) { dc.Interval = atomic.LoadUint32(&s.limitHours) / 24 </s> remove ent := map[string]uint64{} ent[it.Name] = it.Count m = append(m, ent) </s> add m = append(m, map[string]uint64{it.Name: it.Count}) </s> remove func (s *statsCtx) Update(e Entry) { if s.conf.limit == 0 { </s> add func (s *StatsCtx) Update(e Entry) { if !s.isEnabled() { </s> remove if !checkInterval(conf.LimitDays) { conf.LimitDays = 1 </s> add if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) { s.limitHours = 24
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
log.Debug("stats: set limit: %d days", limitDays)
<mask> if limitDays == 0 { <mask> s.clear() <mask> } <mask> <mask> log.Debug("stats: set limit: %d", limitDays) <mask> } <mask> <mask> func (s *statsCtx) WriteDiskConfig(dc *DiskConfig) { <mask> dc.Interval = s.conf.limit / 24 <mask> } </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func (s *statsCtx) WriteDiskConfig(dc *DiskConfig) { dc.Interval = s.conf.limit / 24 </s> add func (s *StatsCtx) WriteDiskConfig(dc *DiskConfig) { dc.Interval = atomic.LoadUint32(&s.limitHours) / 24 </s> remove func (s *statsCtx) setLimit(limitDays int) { s.conf.limit = uint32(limitDays) * 24 </s> add func (s *StatsCtx) setLimit(limitDays int) { atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) </s> remove func (s *statsCtx) Close() { u := s.swapUnit(nil) udb := serialize(u) tx := s.beginTxn(true) if tx != nil { if s.flushUnitToDB(tx, u.id, udb) { </s> add func (s *StatsCtx) Close() { u := s.swapCurrent(nil) db := s.database() if tx := beginTxn(db, true); tx != nil { udb := u.serialize() if flushUnitToDB(tx, u.id, udb) { </s> remove func (s *statsCtx) Update(e Entry) { if s.conf.limit == 0 { </s> add func (s *StatsCtx) Update(e Entry) { if !s.isEnabled() { </s> remove func (s *statsCtx) GetTopClientsIP(maxCount uint) []net.IP { if s.conf.limit == 0 { </s> add func (s *StatsCtx) GetTopClientsIP(maxCount uint) []net.IP { if !s.isEnabled() {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
func (s *StatsCtx) WriteDiskConfig(dc *DiskConfig) { dc.Interval = atomic.LoadUint32(&s.limitHours) / 24
<mask> <mask> log.Debug("stats: set limit: %d", limitDays) <mask> } <mask> <mask> func (s *statsCtx) WriteDiskConfig(dc *DiskConfig) { <mask> dc.Interval = s.conf.limit / 24 <mask> } <mask> <mask> func (s *statsCtx) Close() { <mask> u := s.swapUnit(nil) <mask> udb := serialize(u) </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove log.Debug("stats: set limit: %d", limitDays) </s> add log.Debug("stats: set limit: %d days", limitDays) </s> remove func (s *statsCtx) Close() { u := s.swapUnit(nil) udb := serialize(u) tx := s.beginTxn(true) if tx != nil { if s.flushUnitToDB(tx, u.id, udb) { </s> add func (s *StatsCtx) Close() { u := s.swapCurrent(nil) db := s.database() if tx := beginTxn(db, true); tx != nil { udb := u.serialize() if flushUnitToDB(tx, u.id, udb) { </s> remove func (s *statsCtx) setLimit(limitDays int) { s.conf.limit = uint32(limitDays) * 24 </s> add func (s *StatsCtx) setLimit(limitDays int) { atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) </s> remove func (s *statsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { </s> remove resp.IntervalDays = s.conf.limit / 24 </s> add resp.IntervalDays = s.limitHours / 24
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
func (s *StatsCtx) Close() { u := s.swapCurrent(nil) db := s.database() if tx := beginTxn(db, true); tx != nil { udb := u.serialize() if flushUnitToDB(tx, u.id, udb) {
<mask> func (s *statsCtx) WriteDiskConfig(dc *DiskConfig) { <mask> dc.Interval = s.conf.limit / 24 <mask> } <mask> <mask> func (s *statsCtx) Close() { <mask> u := s.swapUnit(nil) <mask> udb := serialize(u) <mask> tx := s.beginTxn(true) <mask> if tx != nil { <mask> if s.flushUnitToDB(tx, u.id, udb) { <mask> s.commitTxn(tx) <mask> } else { <mask> _ = tx.Rollback() <mask> } <mask> } </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func (s *statsCtx) WriteDiskConfig(dc *DiskConfig) { dc.Interval = s.conf.limit / 24 </s> add func (s *StatsCtx) WriteDiskConfig(dc *DiskConfig) { dc.Interval = atomic.LoadUint32(&s.limitHours) / 24 </s> remove ok1 := s.flushUnitToDB(tx, u.id, udb) ok2 := s.deleteUnit(tx, id-s.conf.limit) if ok1 || ok2 { </s> add flushOK := flushUnitToDB(tx, u.id, udb) delOK := s.deleteUnit(tx, id-atomic.LoadUint32(&s.limitHours)) if flushOK || delOK { </s> remove log.Debug("stats: set limit: %d", limitDays) </s> add log.Debug("stats: set limit: %d days", limitDays) </s> remove nu := unit{} s.initUnit(&nu, id) u := s.swapUnit(&nu) udb := serialize(u) </s> add nu := newUnit(id) u := s.swapCurrent(nu) udb := u.serialize() </s> remove func (s *statsCtx) clear() { tx := s.beginTxn(true) </s> add func (s *StatsCtx) clear() { db := s.database() tx := beginTxn(db, true)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
if db != nil {
<mask> _ = tx.Rollback() <mask> } <mask> } <mask> <mask> if s.db != nil { <mask> log.Tracef("db.Close...") <mask> _ = s.db.Close() <mask> log.Tracef("db.Close") <mask> } <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove _ = s.db.Close() </s> add _ = db.Close() </s> remove db := s.db s.db = nil </s> add _ = s.swapDatabase(nil) </s> remove units = append(units, serialize(cur)) </s> add if cur != nil { units = append(units, cur.serialize()) } </s> remove u := unit{} s.initUnit(&u, s.conf.UnitID()) _ = s.swapUnit(&u) </s> add u := newUnit(s.unitIDGen()) _ = s.swapCurrent(u) </s> remove func (s *statsCtx) clear() { tx := s.beginTxn(true) </s> add func (s *StatsCtx) clear() { db := s.database() tx := beginTxn(db, true)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
_ = db.Close()
<mask> } <mask> <mask> if s.db != nil { <mask> log.Tracef("db.Close...") <mask> _ = s.db.Close() <mask> log.Tracef("db.Close") <mask> } <mask> <mask> log.Debug("stats: closed") <mask> } </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove if s.db != nil { </s> add if db != nil { </s> remove func (s *statsCtx) clear() { tx := s.beginTxn(true) </s> add func (s *StatsCtx) clear() { db := s.database() tx := beginTxn(db, true) </s> remove u := unit{} s.initUnit(&u, s.conf.UnitID()) _ = s.swapUnit(&u) </s> add u := newUnit(s.unitIDGen()) _ = s.swapCurrent(u) </s> remove db := s.db s.db = nil </s> add _ = s.swapDatabase(nil) </s> remove units = append(units, serialize(cur)) </s> add if cur != nil { units = append(units, cur.serialize()) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
func (s *StatsCtx) clear() { db := s.database() tx := beginTxn(db, true)
<mask> log.Debug("stats: closed") <mask> } <mask> <mask> // Reset counters and clear database <mask> func (s *statsCtx) clear() { <mask> tx := s.beginTxn(true) <mask> if tx != nil { <mask> db := s.db <mask> s.db = nil <mask> _ = tx.Rollback() <mask> // the active transactions can continue using database, </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove db := s.db s.db = nil </s> add _ = s.swapDatabase(nil) </s> remove _ = s.db.Close() </s> add _ = db.Close() </s> remove if s.db != nil { </s> add if db != nil { </s> remove func (s *statsCtx) Close() { u := s.swapUnit(nil) udb := serialize(u) tx := s.beginTxn(true) if tx != nil { if s.flushUnitToDB(tx, u.id, udb) { </s> add func (s *StatsCtx) Close() { u := s.swapCurrent(nil) db := s.database() if tx := beginTxn(db, true); tx != nil { udb := u.serialize() if flushUnitToDB(tx, u.id, udb) { </s> remove // Open a DB transaction func (s *statsCtx) beginTxn(wr bool) *bolt.Tx { db := s.db </s> add // beginTxn opens a new database transaction. If writable is true, the // transaction will be opened for writing, and for reading otherwise. It // returns nil if the transaction can't be created. func beginTxn(db *bbolt.DB, writable bool) (tx *bbolt.Tx) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
_ = s.swapDatabase(nil)
<mask> // Reset counters and clear database <mask> func (s *statsCtx) clear() { <mask> tx := s.beginTxn(true) <mask> if tx != nil { <mask> db := s.db <mask> s.db = nil <mask> _ = tx.Rollback() <mask> // the active transactions can continue using database, <mask> // but no new transactions will be opened <mask> _ = db.Close() <mask> log.Tracef("db.Close") </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func (s *statsCtx) clear() { tx := s.beginTxn(true) </s> add func (s *StatsCtx) clear() { db := s.database() tx := beginTxn(db, true) </s> remove if s.db != nil { </s> add if db != nil { </s> remove // Open a DB transaction func (s *statsCtx) beginTxn(wr bool) *bolt.Tx { db := s.db </s> add // beginTxn opens a new database transaction. If writable is true, the // transaction will be opened for writing, and for reading otherwise. It // returns nil if the transaction can't be created. func beginTxn(db *bbolt.DB, writable bool) (tx *bbolt.Tx) { </s> remove u := unit{} s.initUnit(&u, s.conf.UnitID()) _ = s.swapUnit(&u) </s> add u := newUnit(s.unitIDGen()) _ = s.swapCurrent(u) </s> remove _ = s.db.Close() </s> add _ = db.Close()
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
u := newUnit(s.unitIDGen()) _ = s.swapCurrent(u)
<mask> log.Tracef("db.Close") <mask> // all active transactions are now closed <mask> } <mask> <mask> u := unit{} <mask> s.initUnit(&u, s.conf.UnitID()) <mask> _ = s.swapUnit(&u) <mask> <mask> err := os.Remove(s.conf.Filename) <mask> if err != nil { <mask> log.Error("os.Remove: %s", err) <mask> } </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove err := os.Remove(s.conf.Filename) </s> add err := os.Remove(s.filename) </s> remove db := s.db s.db = nil </s> add _ = s.swapDatabase(nil) </s> remove u := unit{} s.initUnit(&u, id) if udb != nil { deserialize(&u, udb) } s.current = &u </s> add u := newUnit(id) // This use of deserialize is safe since the accessed unit has just been // created. u.deserialize(udb) s.curr = u </s> remove log.Error("db.Begin: %s", err) </s> add log.Error("stats: opening a transaction: %s", err) </s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
err := os.Remove(s.filename)
<mask> u := unit{} <mask> s.initUnit(&u, s.conf.UnitID()) <mask> _ = s.swapUnit(&u) <mask> <mask> err := os.Remove(s.conf.Filename) <mask> if err != nil { <mask> log.Error("os.Remove: %s", err) <mask> } <mask> <mask> _ = s.dbOpen() </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove u := unit{} s.initUnit(&u, s.conf.UnitID()) _ = s.swapUnit(&u) </s> add u := newUnit(s.unitIDGen()) _ = s.swapCurrent(u) </s> remove log.Error("db.Begin: %s", err) </s> add log.Error("stats: opening a transaction: %s", err) </s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err) </s> remove u := unit{} s.initUnit(&u, id) if udb != nil { deserialize(&u, udb) } s.current = &u </s> add u := newUnit(id) // This use of deserialize is safe since the accessed unit has just been // created. u.deserialize(udb) s.curr = u </s> remove ) (f func(name []byte, b *bolt.Bucket) (err error)) { return func(name []byte, _ *bolt.Bucket) (err error) { </s> add ) (f func(name []byte, b *bbolt.Bucket) (err error)) { return func(name []byte, _ *bbolt.Bucket) (err error) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
func (s *StatsCtx) Update(e Entry) { if !s.isEnabled() {
<mask> <mask> log.Debug("stats: cleared") <mask> } <mask> <mask> func (s *statsCtx) Update(e Entry) { <mask> if s.conf.limit == 0 { <mask> return <mask> } <mask> <mask> if e.Result == 0 || <mask> e.Result >= rLast || </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove e.Result >= rLast || </s> add e.Result >= resultLast || </s> remove func checkInterval(days uint32) bool { </s> add // checkInterval returns true if days is valid to be used as statistics // retention interval. The valid values are 0, 1, 7, 30 and 90. func checkInterval(days uint32) (ok bool) { </s> remove func (s *statsCtx) dbOpen() bool { var err error </s> add // dbOpen returns an error if the database can't be opened from the specified // file. It's safe for concurrent use. func (s *StatsCtx) dbOpen() (err error) { </s> remove log.Debug("stats: set limit: %d", limitDays) </s> add log.Debug("stats: set limit: %d days", limitDays) </s> remove func (s *statsCtx) setLimit(limitDays int) { s.conf.limit = uint32(limitDays) * 24 </s> add func (s *StatsCtx) setLimit(limitDays int) { atomic.StoreUint32(&s.limitHours, uint32(24*limitDays))
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
e.Result >= resultLast ||
<mask> return <mask> } <mask> <mask> if e.Result == 0 || <mask> e.Result >= rLast || <mask> e.Domain == "" || <mask> e.Client == "" { <mask> return <mask> } <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func (s *statsCtx) Update(e Entry) { if s.conf.limit == 0 { </s> add func (s *StatsCtx) Update(e Entry) { if !s.isEnabled() { </s> remove func checkInterval(days uint32) bool { </s> add // checkInterval returns true if days is valid to be used as statistics // retention interval. The valid values are 0, 1, 7, 30 and 90. func checkInterval(days uint32) (ok bool) { </s> remove func (s *statsCtx) dbOpen() bool { var err error </s> add // dbOpen returns an error if the database can't be opened from the specified // file. It's safe for concurrent use. func (s *StatsCtx) dbOpen() (err error) { </s> remove ok1 := s.flushUnitToDB(tx, u.id, udb) ok2 := s.deleteUnit(tx, id-s.conf.limit) if ok1 || ok2 { </s> add flushOK := flushUnitToDB(tx, u.id, udb) delOK := s.deleteUnit(tx, id-atomic.LoadUint32(&s.limitHours)) if flushOK || delOK { </s> remove func (s *statsCtx) periodicFlush() { for { ptr := s.ongoing() if ptr == nil { break } id := s.conf.UnitID() if ptr.id == id || s.conf.limit == 0 { </s> add func (s *StatsCtx) periodicFlush() { for ptr := s.ongoing(); ptr != nil; ptr = s.ongoing() { id := s.unitIDGen() // Access the unit's ID with atomic to avoid locking the whole unit. if !s.isEnabled() || atomic.LoadUint32(&ptr.id) == id {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
u := s.ongoing() if u == nil { return }
<mask> if ip := net.ParseIP(clientID); ip != nil { <mask> clientID = ip.String() <mask> } <mask> <mask> s.mu.Lock() <mask> defer s.mu.Unlock() <mask> <mask> u := s.current <mask> <mask> u.nResult[e.Result]++ <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove u := s.current </s> add u.mu.Lock() defer u.mu.Unlock() </s> remove u = s.current s.current = new </s> add log.Tracef("db.Open") </s> remove // Atomically swap the currently active unit with a new value // Return old value func (s *statsCtx) swapUnit(new *unit) (u *unit) { s.mu.Lock() defer s.mu.Unlock() </s> add return err } </s> remove u := unit{} s.initUnit(&u, id) if udb != nil { deserialize(&u, udb) } s.current = &u </s> add u := newUnit(id) // This use of deserialize is safe since the accessed unit has just been // created. u.deserialize(udb) s.curr = u </s> remove return u </s> add return nil
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
u.mu.Lock() defer u.mu.Unlock()
<mask> <mask> s.mu.Lock() <mask> defer s.mu.Unlock() <mask> <mask> u := s.current <mask> <mask> u.nResult[e.Result]++ <mask> <mask> if e.Result == RNotFiltered { <mask> u.domains[e.Domain]++ </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove s.mu.Lock() defer s.mu.Unlock() </s> add u := s.ongoing() if u == nil { return } </s> remove u = s.current s.current = new </s> add log.Tracef("db.Open") </s> remove // Atomically swap the currently active unit with a new value // Return old value func (s *statsCtx) swapUnit(new *unit) (u *unit) { s.mu.Lock() defer s.mu.Unlock() </s> add return err } </s> remove e.Result >= rLast || </s> add e.Result >= resultLast || </s> remove func (s *statsCtx) Update(e Entry) { if s.conf.limit == 0 { </s> add func (s *StatsCtx) Update(e Entry) { if !s.isEnabled() {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
func (s *StatsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) { tx := beginTxn(s.database(), false)
<mask> u.timeSum += uint64(e.Time) <mask> u.nTotal++ <mask> } <mask> <mask> func (s *statsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) { <mask> tx := s.beginTxn(false) <mask> if tx == nil { <mask> return nil, 0 <mask> } <mask> <mask> cur := s.ongoing() </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove curID := cur.id </s> add var curID uint32 if cur != nil { curID = atomic.LoadUint32(&cur.id) } else { curID = s.unitIDGen() } </s> remove func (s *statsCtx) loadUnitFromDB(tx *bolt.Tx, id uint32) *unitDB { </s> add func (s *StatsCtx) loadUnitFromDB(tx *bbolt.Tx, id uint32) *unitDB { </s> remove id := s.conf.UnitID() tx := s.beginTxn(true) </s> add id := s.unitIDGen() tx := beginTxn(s.db, true) </s> remove func (s *statsCtx) Close() { u := s.swapUnit(nil) udb := serialize(u) tx := s.beginTxn(true) if tx != nil { if s.flushUnitToDB(tx, u.id, udb) { </s> add func (s *StatsCtx) Close() { u := s.swapCurrent(nil) db := s.database() if tx := beginTxn(db, true); tx != nil { udb := u.serialize() if flushUnitToDB(tx, u.id, udb) { </s> remove if !s.dbOpen() { return nil, fmt.Errorf("open database") </s> add if err = s.dbOpen(); err != nil { return nil, fmt.Errorf("opening database: %w", err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
var curID uint32 if cur != nil { curID = atomic.LoadUint32(&cur.id) } else { curID = s.unitIDGen() }
<mask> return nil, 0 <mask> } <mask> <mask> cur := s.ongoing() <mask> curID := cur.id <mask> <mask> // Per-hour units. <mask> units := []*unitDB{} <mask> firstID := curID - limit + 1 <mask> for i := firstID; i != curID; i++ { </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove u.NResult = make([]uint64, rLast) </s> add u.NResult = make([]uint64, resultLast) </s> remove id := s.conf.UnitID() tx := s.beginTxn(true) </s> add id := s.unitIDGen() tx := beginTxn(s.db, true) </s> remove func (s *statsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) { tx := s.beginTxn(false) </s> add func (s *StatsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) { tx := beginTxn(s.database(), false) </s> remove firstID := id - s.conf.limit - 1 </s> add firstID := id - s.limitHours - 1 </s> remove func deserialize(u *unit, udb *unitDB) { u.nTotal = udb.NTotal n := len(udb.NResult) if n < len(u.nResult) { n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult)) } for i := 1; i < n; i++ { u.nResult[i] = udb.NResult[i] </s> add // deserealize assigns the appropriate values from udb to u. u must not be nil. // It's safe for concurrent use. func (u *unit) deserialize(udb *unitDB) { if udb == nil { return
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
u.NResult = make([]uint64, resultLast)
<mask> for i := firstID; i != curID; i++ { <mask> u := s.loadUnitFromDB(tx, i) <mask> if u == nil { <mask> u = &unitDB{} <mask> u.NResult = make([]uint64, rLast) <mask> } <mask> units = append(units, u) <mask> } <mask> <mask> _ = tx.Rollback() </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove curID := cur.id </s> add var curID uint32 if cur != nil { curID = atomic.LoadUint32(&cur.id) } else { curID = s.unitIDGen() } </s> remove units = append(units, serialize(cur)) </s> add if cur != nil { units = append(units, cur.serialize()) } </s> remove func deserialize(u *unit, udb *unitDB) { u.nTotal = udb.NTotal n := len(udb.NResult) if n < len(u.nResult) { n = len(u.nResult) // n = min(len(udb.NResult), len(u.nResult)) } for i := 1; i < n; i++ { u.nResult[i] = udb.NResult[i] </s> add // deserealize assigns the appropriate values from udb to u. u must not be nil. // It's safe for concurrent use. func (u *unit) deserialize(udb *unitDB) { if udb == nil { return </s> remove s.mu.Lock() defer s.mu.Unlock() </s> add u := s.ongoing() if u == nil { return } </s> remove NResult: make([]uint64, rLast), </s> add NResult: make([]uint64, resultLast),
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
if cur != nil { units = append(units, cur.serialize()) }
<mask> } <mask> <mask> _ = tx.Rollback() <mask> <mask> units = append(units, serialize(cur)) <mask> <mask> if len(units) != int(limit) { <mask> log.Fatalf("len(units) != limit: %d %d", len(units), limit) <mask> } <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove u.NResult = make([]uint64, rLast) </s> add u.NResult = make([]uint64, resultLast) </s> remove log.Debug("stats: set limit: %d", limitDays) </s> add log.Debug("stats: set limit: %d days", limitDays) </s> remove if s.db != nil { </s> add if db != nil { </s> remove func (s *statsCtx) setLimit(limitDays int) { s.conf.limit = uint32(limitDays) * 24 </s> add func (s *StatsCtx) setLimit(limitDays int) { atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) </s> remove _ = s.db.Close() </s> add _ = db.Close()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// topsCollector collects statistics about highest values from the given *unitDB
<mask> <mask> // pairsGetter is a signature for topsCollector argument. <mask> type pairsGetter func(u *unitDB) (pairs []countPair) <mask> <mask> // topsCollector collects statistics about highest values fro the given *unitDB <mask> // slice using pg to retrieve data. <mask> func topsCollector(units []*unitDB, max int, pg pairsGetter) []map[string]uint64 { <mask> m := map[string]uint64{} <mask> for _, u := range units { <mask> for _, it := range pg(u) { </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove for _, it := range pg(u) { m[it.Name] += it.Count </s> add for _, cp := range pg(u) { m[cp.Name] += cp.Count </s> remove func convertTopSlice(a []countPair) []map[string]uint64 { m := []map[string]uint64{} </s> add func convertTopSlice(a []countPair) (m []map[string]uint64) { m = make([]map[string]uint64, 0, len(a)) </s> remove ent := map[string]uint64{} ent[it.Name] = it.Count m = append(m, ent) </s> add m = append(m, map[string]uint64{it.Name: it.Count}) </s> remove NResult: make([]uint64, rLast), </s> add NResult: make([]uint64, resultLast), </s> remove pair := countPair{} pair.Name = k pair.Count = v a = append(a, pair) </s> add a = append(a, countPair{Name: k, Count: v})
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
for _, cp := range pg(u) { m[cp.Name] += cp.Count
<mask> // slice using pg to retrieve data. <mask> func topsCollector(units []*unitDB, max int, pg pairsGetter) []map[string]uint64 { <mask> m := map[string]uint64{} <mask> for _, u := range units { <mask> for _, it := range pg(u) { <mask> m[it.Name] += it.Count <mask> } <mask> } <mask> a2 := convertMapToSlice(m, max) <mask> return convertTopSlice(a2) <mask> } </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove // topsCollector collects statistics about highest values fro the given *unitDB </s> add // topsCollector collects statistics about highest values from the given *unitDB </s> remove ent := map[string]uint64{} ent[it.Name] = it.Count m = append(m, ent) </s> add m = append(m, map[string]uint64{it.Name: it.Count}) </s> remove func convertTopSlice(a []countPair) []map[string]uint64 { m := []map[string]uint64{} </s> add func convertTopSlice(a []countPair) (m []map[string]uint64) { m = make([]map[string]uint64, 0, len(a)) </s> remove NResult: make([]uint64, rLast), </s> add NResult: make([]uint64, resultLast), </s> remove pair := countPair{} pair.Name = k pair.Count = v a = append(a, pair) </s> add a = append(a, countPair{Name: k, Count: v})
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
func (s *StatsCtx) getData() (statsResponse, bool) { limit := atomic.LoadUint32(&s.limitHours) if limit == 0 { return statsResponse{ TimeUnits: "days", TopBlocked: []topAddrs{}, TopClients: []topAddrs{}, TopQueried: []topAddrs{}, BlockedFiltering: []uint64{}, DNSQueries: []uint64{}, ReplacedParental: []uint64{}, ReplacedSafebrowsing: []uint64{}, }, true }
<mask> * safesearch-blocked <mask> * parental-blocked <mask> These values are just the sum of data for all units. <mask> */ <mask> func (s *statsCtx) getData() (statsResponse, bool) { <mask> limit := s.conf.limit <mask> <mask> timeUnit := Hours <mask> if limit/24 > 7 { <mask> timeUnit = Days <mask> } </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func (s *statsCtx) setLimit(limitDays int) { s.conf.limit = uint32(limitDays) * 24 </s> add func (s *StatsCtx) setLimit(limitDays int) { atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) </s> remove func checkInterval(days uint32) bool { </s> add // checkInterval returns true if days is valid to be used as statistics // retention interval. The valid values are 0, 1, 7, 30 and 90. func checkInterval(days uint32) (ok bool) { </s> remove if !checkInterval(conf.LimitDays) { conf.LimitDays = 1 </s> add if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) { s.limitHours = 24 </s> remove // Initialize a unit func (s *statsCtx) initUnit(u *unit, id uint32) { u.id = id u.nResult = make([]uint64, rLast) u.domains = make(map[string]uint64) u.blockedDomains = make(map[string]uint64) u.clients = make(map[string]uint64) </s> add // newUnit allocates the new *unit. func newUnit(id uint32) (u *unit) { return &unit{ mu: &sync.RWMutex{}, id: id, nResult: make([]uint64, resultLast), domains: make(map[string]uint64), blockedDomains: make(map[string]uint64), clients: make(map[string]uint64), } </s> remove curID := cur.id </s> add var curID uint32 if cur != nil { curID = atomic.LoadUint32(&cur.id) } else { curID = s.unitIDGen() }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
NResult: make([]uint64, resultLast),
<mask> } <mask> <mask> // Total counters: <mask> sum := unitDB{ <mask> NResult: make([]uint64, rLast), <mask> } <mask> timeN := 0 <mask> for _, u := range units { <mask> sum.NTotal += u.NTotal <mask> sum.TimeAvg += u.TimeAvg </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove for _, it := range pg(u) { m[it.Name] += it.Count </s> add for _, cp := range pg(u) { m[cp.Name] += cp.Count </s> remove u.NResult = make([]uint64, rLast) </s> add u.NResult = make([]uint64, resultLast) </s> remove // topsCollector collects statistics about highest values fro the given *unitDB </s> add // topsCollector collects statistics about highest values from the given *unitDB </s> remove func (s *statsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) { tx := s.beginTxn(false) </s> add func (s *StatsCtx) loadUnits(limit uint32) ([]*unitDB, uint32) { tx := beginTxn(s.database(), false) </s> remove func convertTopSlice(a []countPair) []map[string]uint64 { m := []map[string]uint64{} </s> add func convertTopSlice(a []countPair) (m []map[string]uint64) { m = make([]map[string]uint64, 0, len(a))
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
func (s *StatsCtx) GetTopClientsIP(maxCount uint) []net.IP { if !s.isEnabled() {
<mask> <mask> return data, true <mask> } <mask> <mask> func (s *statsCtx) GetTopClientsIP(maxCount uint) []net.IP { <mask> if s.conf.limit == 0 { <mask> return nil <mask> } <mask> <mask> units, _ := s.loadUnits(s.conf.limit) <mask> if units == nil { </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove units, _ := s.loadUnits(s.conf.limit) </s> add units, _ := s.loadUnits(atomic.LoadUint32(&s.limitHours)) </s> remove func (s *statsCtx) loadUnitFromDB(tx *bolt.Tx, id uint32) *unitDB { </s> add func (s *StatsCtx) loadUnitFromDB(tx *bbolt.Tx, id uint32) *unitDB { </s> remove func (s *statsCtx) Update(e Entry) { if s.conf.limit == 0 { </s> add func (s *StatsCtx) Update(e Entry) { if !s.isEnabled() { </s> remove func (s *statsCtx) setLimit(limitDays int) { s.conf.limit = uint32(limitDays) * 24 </s> add func (s *StatsCtx) setLimit(limitDays int) { atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) </s> remove func (s *statsCtx) initWeb() { if s.conf.HTTPRegister == nil { </s> add func (s *StatsCtx) initWeb() { if s.httpRegister == nil {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
units, _ := s.loadUnits(atomic.LoadUint32(&s.limitHours))
<mask> if s.conf.limit == 0 { <mask> return nil <mask> } <mask> <mask> units, _ := s.loadUnits(s.conf.limit) <mask> if units == nil { <mask> return nil <mask> } <mask> <mask> // top clients </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP </s> remove func (s *statsCtx) GetTopClientsIP(maxCount uint) []net.IP { if s.conf.limit == 0 { </s> add func (s *StatsCtx) GetTopClientsIP(maxCount uint) []net.IP { if !s.isEnabled() { </s> remove u.NResult = make([]uint64, rLast) </s> add u.NResult = make([]uint64, resultLast) </s> remove func (s *statsCtx) Update(e Entry) { if s.conf.limit == 0 { </s> add func (s *StatsCtx) Update(e Entry) { if !s.isEnabled() { </s> remove func (s *statsCtx) initWeb() { if s.conf.HTTPRegister == nil { </s> add func (s *StatsCtx) initWeb() { if s.httpRegister == nil { </s> remove units = append(units, serialize(cur)) </s> add if cur != nil { units = append(units, cur.serialize()) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
"install_devices_android_list_5": "Change DNS 1 and DNS 2 values to your AdGuard Home server addresses.",
<mask> "install_devices_android_list_1": "From the Android Menu home screen, tap Settings.", <mask> "install_devices_android_list_2": "Tap Wi-Fi on the menu. The screen listing all of the available networks will be shown (it is impossible to set custom DNS for mobile connection).", <mask> "install_devices_android_list_3": "Long press the network you're connected to, and tap Modify Network.", <mask> "install_devices_android_list_4": "On some devices, you may need to check the box for Advanced to see further settings. To adjust your Android DNS settings, you will need to switch the IP settings from DHCP to Static.", <mask> "install_devices_android_list_5": "Change set DNS 1 and DNS 2 values to your AdGuard Home server addresses.", <mask> "install_devices_ios_list_1": "From the home screen, tap Settings.", <mask> "install_devices_ios_list_2": "Choose Wi-Fi in the left menu (it is impossible to configure DNS for mobile networks).", <mask> "install_devices_ios_list_3": "Tap on the name of the currently active network.", <mask> "install_devices_ios_list_4": "In the DNS field enter your AdGuard Home server addresses.", <mask> "get_started": "Get Started", </s> Pull request: client: imp en locale Merge in DNS/adguard-home from imp-i18n-en to master Squashed commit of the following: commit 7d0f46dc0a9b28e709ac9ad1748b17ae9ad4a520 Author: Ainar Garipov <[email protected]> Date: Thu May 13 16:04:22 2021 +0300 client: imp en locale </s> remove "client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.", </s> add "client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address, or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.", </s> remove "filter_category_security_desc": "Lists that specialize on blocking malware, phishing or scam domains", </s> add "filter_category_security_desc": "Lists that specialize on blocking malware, phishing, or scam domains", </s> remove "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards and URL filter rules, e.g. \"example.org\", \"*.example.org\" or \"||example.org^\".", </s> add "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards, and URL filter rules, e.g. \"example.org\", \"*.example.org\", or \"||example.org^\".",
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/42ec9cae76bd747391d670c6a046ec4800ca60f5
client/src/__locales/en.json
"client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address, or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.",
<mask> "client_new": "New Client", <mask> "client_edit": "Edit Client", <mask> "client_identifier": "Identifier", <mask> "ip_address": "IP address", <mask> "client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.", <mask> "form_enter_ip": "Enter IP", <mask> "form_enter_subnet_ip": "Enter an IP address in the subnet \"{{cidr}}\"", <mask> "form_enter_mac": "Enter MAC", <mask> "form_enter_id": "Enter identifier", <mask> "form_add_id": "Add identifier", </s> Pull request: client: imp en locale Merge in DNS/adguard-home from imp-i18n-en to master Squashed commit of the following: commit 7d0f46dc0a9b28e709ac9ad1748b17ae9ad4a520 Author: Ainar Garipov <[email protected]> Date: Thu May 13 16:04:22 2021 +0300 client: imp en locale </s> remove "install_devices_android_list_5": "Change set DNS 1 and DNS 2 values to your AdGuard Home server addresses.", </s> add "install_devices_android_list_5": "Change DNS 1 and DNS 2 values to your AdGuard Home server addresses.", </s> remove "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards and URL filter rules, e.g. \"example.org\", \"*.example.org\" or \"||example.org^\".", </s> add "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards, and URL filter rules, e.g. \"example.org\", \"*.example.org\", or \"||example.org^\".", </s> remove "filter_category_security_desc": "Lists that specialize on blocking malware, phishing or scam domains", </s> add "filter_category_security_desc": "Lists that specialize on blocking malware, phishing, or scam domains",
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/42ec9cae76bd747391d670c6a046ec4800ca60f5
client/src/__locales/en.json
"access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards, and URL filter rules, e.g. \"example.org\", \"*.example.org\", or \"||example.org^\".",
<mask> "access_allowed_desc": "A list of CIDR or IP addresses. If configured, AdGuard Home will accept requests from these IP addresses only.", <mask> "access_disallowed_title": "Disallowed clients", <mask> "access_disallowed_desc": "A list of CIDR or IP addresses. If configured, AdGuard Home will drop requests from these IP addresses.", <mask> "access_blocked_title": "Disallowed domains", <mask> "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards and URL filter rules, e.g. \"example.org\", \"*.example.org\" or \"||example.org^\".", <mask> "access_settings_saved": "Access settings successfully saved", <mask> "updates_checked": "Updates successfully checked", <mask> "updates_version_equal": "AdGuard Home is up-to-date", <mask> "check_updates_now": "Check for updates now", <mask> "dns_privacy": "DNS Privacy", </s> Pull request: client: imp en locale Merge in DNS/adguard-home from imp-i18n-en to master Squashed commit of the following: commit 7d0f46dc0a9b28e709ac9ad1748b17ae9ad4a520 Author: Ainar Garipov <[email protected]> Date: Thu May 13 16:04:22 2021 +0300 client: imp en locale </s> remove "client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.", </s> add "client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address, or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.", </s> remove "install_devices_android_list_5": "Change set DNS 1 and DNS 2 values to your AdGuard Home server addresses.", </s> add "install_devices_android_list_5": "Change DNS 1 and DNS 2 values to your AdGuard Home server addresses.", </s> remove "filter_category_security_desc": "Lists that specialize on blocking malware, phishing or scam domains", </s> add "filter_category_security_desc": "Lists that specialize on blocking malware, phishing, or scam domains",
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/42ec9cae76bd747391d670c6a046ec4800ca60f5
client/src/__locales/en.json
"filter_category_security_desc": "Lists that specialize on blocking malware, phishing, or scam domains",
<mask> "filter_category_security": "Security", <mask> "filter_category_regional": "Regional", <mask> "filter_category_other": "Other", <mask> "filter_category_general_desc": "Lists that block tracking and advertising on most of the devices", <mask> "filter_category_security_desc": "Lists that specialize on blocking malware, phishing or scam domains", <mask> "filter_category_regional_desc": "Lists that focus on regional ads and tracking servers", <mask> "filter_category_other_desc": "Other blocklists", <mask> "setup_config_to_enable_dhcp_server": "Setup configuration to enable DHCP server", <mask> "original_response": "Original response", <mask> "click_to_view_queries": "Click to view queries", </s> Pull request: client: imp en locale Merge in DNS/adguard-home from imp-i18n-en to master Squashed commit of the following: commit 7d0f46dc0a9b28e709ac9ad1748b17ae9ad4a520 Author: Ainar Garipov <[email protected]> Date: Thu May 13 16:04:22 2021 +0300 client: imp en locale </s> remove "install_devices_android_list_5": "Change set DNS 1 and DNS 2 values to your AdGuard Home server addresses.", </s> add "install_devices_android_list_5": "Change DNS 1 and DNS 2 values to your AdGuard Home server addresses.", </s> remove "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards and URL filter rules, e.g. \"example.org\", \"*.example.org\" or \"||example.org^\".", </s> add "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in queries' questions. Here you can specify the exact domain names, wildcards, and URL filter rules, e.g. \"example.org\", \"*.example.org\", or \"||example.org^\".", </s> remove "client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.", </s> add "client_identifier_desc": "Clients can be identified by the IP address, CIDR, MAC address, or a special client ID (can be used for DoT/DoH/DoQ). <0>Here</0> you can learn more about how to identify clients.",
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/42ec9cae76bd747391d670c6a046ec4800ca60f5
client/src/__locales/en.json
CacheSize uint32 `json:"cache_size"` CacheMinTTL uint32 `json:"cache_ttl_min"` CacheMaxTTL uint32 `json:"cache_ttl_max"`
<mask> DisableIPv6 bool `json:"disable_ipv6"` <mask> UpstreamMode string `json:"upstream_mode"` <mask> } <mask> <mask> func (s *Server) handleGetConfig(w http.ResponseWriter, r *http.Request) { <mask> resp := dnsConfigJSON{} </s> + dns: new settings for cache Squashed commit of the following: commit e5b488249a4d972efd63c6e96830d9f30829aee1 Author: Simon Zolin <[email protected]> Date: Tue Jun 16 15:38:27 2020 +0300 + dns: new settings for cache
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4303b3dd2f6c4e1f64e8cd8575070de35b3d6df7
dnsforward/dnsforward_http.go
resp.CacheSize = s.conf.CacheSize resp.CacheMinTTL = s.conf.CacheMinTTL resp.CacheMaxTTL = s.conf.CacheMaxTTL
<mask> resp.DNSSECEnabled = s.conf.EnableDNSSEC <mask> resp.DisableIPv6 = s.conf.AAAADisabled <mask> if s.conf.FastestAddr { <mask> resp.UpstreamMode = "fastest_addr" <mask> } else if s.conf.AllServers { <mask> resp.UpstreamMode = "parallel" <mask> } </s> + dns: new settings for cache Squashed commit of the following: commit e5b488249a4d972efd63c6e96830d9f30829aee1 Author: Simon Zolin <[email protected]> Date: Tue Jun 16 15:38:27 2020 +0300 + dns: new settings for cache
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4303b3dd2f6c4e1f64e8cd8575070de35b3d6df7
dnsforward/dnsforward_http.go
if req.CacheMinTTL > req.CacheMaxTTL { httpError(r, w, http.StatusBadRequest, "cache_ttl_min must be less or equal than cache_ttl_max") return }
<mask> return <mask> } <mask> <mask> restart := false <mask> s.Lock() <mask> <mask> if js.Exists("upstream_dns") { <mask> s.conf.UpstreamDNS = req.Upstreams <mask> restart = true </s> + dns: new settings for cache Squashed commit of the following: commit e5b488249a4d972efd63c6e96830d9f30829aee1 Author: Simon Zolin <[email protected]> Date: Tue Jun 16 15:38:27 2020 +0300 + dns: new settings for cache
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4303b3dd2f6c4e1f64e8cd8575070de35b3d6df7
dnsforward/dnsforward_http.go
if js.Exists("cache_size") { s.conf.CacheSize = req.CacheSize restart = true } if js.Exists("cache_ttl_min") { s.conf.CacheMinTTL = req.CacheMinTTL restart = true } if js.Exists("cache_ttl_max") { s.conf.CacheMaxTTL = req.CacheMaxTTL restart = true }
<mask> s.conf.AAAADisabled = req.DisableIPv6 <mask> } <mask> <mask> if js.Exists("upstream_mode") { <mask> s.conf.FastestAddr = false <mask> s.conf.AllServers = false <mask> switch req.UpstreamMode { <mask> case "": <mask> // </s> + dns: new settings for cache Squashed commit of the following: commit e5b488249a4d972efd63c6e96830d9f30829aee1 Author: Simon Zolin <[email protected]> Date: Tue Jun 16 15:38:27 2020 +0300 + dns: new settings for cache
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4303b3dd2f6c4e1f64e8cd8575070de35b3d6df7
dnsforward/dnsforward_http.go
cache_size: type: integer cache_ttl_min: type: integer cache_ttl_max: type: integer
<mask> edns_cs_enabled: <mask> type: boolean <mask> dnssec_enabled: <mask> type: boolean <mask> upstream_mode: <mask> enum: <mask> - "" <mask> - parallel <mask> - fastest_addr </s> + dns: new settings for cache Squashed commit of the following: commit e5b488249a4d972efd63c6e96830d9f30829aee1 Author: Simon Zolin <[email protected]> Date: Tue Jun 16 15:38:27 2020 +0300 + dns: new settings for cache
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4303b3dd2f6c4e1f64e8cd8575070de35b3d6df7
openapi/openapi.yaml
"tiny-version-compare": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/tiny-version-compare/-/tiny-version-compare-0.9.1.tgz", "integrity": "sha512-kYim94l7ptSmj9rqxUMkrcMCJ448CS+hwqjA7OFcRi0ISdi0zjgdSUklQ4velVVECCjCo5frU3tNZ3oSgIKzsA==" },
<mask> } <mask> }, <mask> "tmp": { <mask> "version": "0.0.33", <mask> "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", <mask> "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", <mask> "dev": true, <mask> "requires": { </s> Add update check Closes #338 </s> remove font-size: 0.9rem; </s> add font-size: 0.85rem;
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/package-lock.json
"tiny-version-compare": "^0.9.1",
<mask> "svg-url-loader": "^2.3.2", <mask> "tabler-react": "^1.10.0", <mask> "whatwg-fetch": "2.0.3" <mask> }, <mask> "devDependencies": { <mask> "autoprefixer": "^8.6.3", <mask> "babel-core": "6.26.0", <mask> "babel-eslint": "^8.2.3", </s> Add update check Closes #338
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/package.json
export const getVersionRequest = createAction('GET_VERSION_REQUEST'); export const getVersionFailure = createAction('GET_VERSION_FAILURE'); export const getVersionSuccess = createAction('GET_VERSION_SUCCESS'); export const getVersion = () => async (dispatch) => { dispatch(getVersionRequest()); try { const newVersion = await apiClient.getGlobalVersion(); dispatch(getVersionSuccess(newVersion)); } catch (error) { dispatch(addErrorToast({ error })); dispatch(getVersionFailure()); } };
<mask> dispatch(getStatsFailure()); <mask> } <mask> }; <mask> <mask> export const getTopStatsRequest = createAction('GET_TOP_STATS_REQUEST'); <mask> export const getTopStatsFailure = createAction('GET_TOP_STATS_FAILURE'); <mask> export const getTopStatsSuccess = createAction('GET_TOP_STATS_SUCCESS'); <mask> <mask> export const getTopStats = () => async (dispatch, getState) => { </s> Add update check Closes #338 </s> remove version {dnsVersion} / address: {dnsAddress}:{dnsPort} </s> add <div className="nav-version__text"> version: <span className="nav-version__value">{dnsVersion}</span> </div> <div className="nav-version__text"> address: <span className="nav-version__value">{dnsAddress}:{dnsPort}</span> </div>
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/src/actions/index.js
GLOBAL_VERSION = { path: 'version.json', method: 'GET' };
<mask> GLOBAL_QUERY_LOG = { path: 'querylog', method: 'GET' }; <mask> GLOBAL_QUERY_LOG_ENABLE = { path: 'querylog_enable', method: 'POST' }; <mask> GLOBAL_QUERY_LOG_DISABLE = { path: 'querylog_disable', method: 'POST' }; <mask> GLOBAL_SET_UPSTREAM_DNS = { path: 'set_upstream_dns', method: 'POST' }; <mask> <mask> restartGlobalFiltering() { <mask> const { path, method } = this.GLOBAL_RESTART; <mask> return this.makeRequest(path, method); </s> Add update check Closes #338 </s> remove version {dnsVersion} / address: {dnsAddress}:{dnsPort} </s> add <div className="nav-version__text"> version: <span className="nav-version__value">{dnsVersion}</span> </div> <div className="nav-version__text"> address: <span className="nav-version__value">{dnsAddress}:{dnsPort}</span> </div>
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/src/api/Api.js
getGlobalVersion() { const { path, method } = this.GLOBAL_VERSION; return this.makeRequest(path, method); }
<mask> return this.makeRequest(path, method, config); <mask> } <mask> <mask> // Filtering <mask> FILTERING_STATUS = { path: 'filtering/status', method: 'GET' }; <mask> FILTERING_ENABLE = { path: 'filtering/enable', method: 'POST' }; <mask> FILTERING_DISABLE = { path: 'filtering/disable', method: 'POST' }; <mask> FILTERING_ADD_FILTER = { path: 'filtering/add_url', method: 'PUT' }; </s> Add update check Closes #338 </s> remove version {dnsVersion} / address: {dnsAddress}:{dnsPort} </s> add <div className="nav-version__text"> version: <span className="nav-version__value">{dnsVersion}</span> </div> <div className="nav-version__text"> address: <span className="nav-version__value">{dnsAddress}:{dnsPort}</span> </div>
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/src/api/Api.js
import Update from '../ui/Update';
<mask> import Toasts from '../Toasts'; <mask> import Status from '../ui/Status'; <mask> <mask> class App extends Component { <mask> componentDidMount() { <mask> this.props.getDnsStatus(); <mask> this.props.getVersion(); </s> Add update check Closes #338
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/src/components/App/index.js
this.props.getVersion();
<mask> <mask> class App extends Component { <mask> componentDidMount() { <mask> this.props.getDnsStatus(); <mask> } <mask> <mask> handleStatusChange = () => { <mask> this.props.enableDns(); <mask> }; </s> Add update check Closes #338
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/src/components/App/index.js
const updateAvailable = !dashboard.processingVersions && dashboard.isCoreRunning && dashboard.isUpdateAvailable;
<mask> }; <mask> <mask> render() { <mask> const { dashboard } = this.props; <mask> return ( <mask> <HashRouter hashType='noslash'> <mask> <Fragment> <mask> {updateAvailable && <mask> <Update </s> Add update check Closes #338 </s> remove version {dnsVersion} / address: {dnsAddress}:{dnsPort} </s> add <div className="nav-version__text"> version: <span className="nav-version__value">{dnsVersion}</span> </div> <div className="nav-version__text"> address: <span className="nav-version__value">{dnsAddress}:{dnsPort}</span> </div>
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/src/components/App/index.js
{updateAvailable && <Update announcement={dashboard.announcement} announcementUrl={dashboard.announcementUrl} /> }
<mask> <HashRouter hashType='noslash'> <mask> <Fragment> <mask> <LoadingBar className="loading-bar" updateTime={1000} /> <mask> <Route component={Header} /> <mask> <div className="container container--wrap"> <mask> {!dashboard.processing && !dashboard.isCoreRunning && <mask> <div className="row row-cards"> <mask> <div className="col-lg-12"> </s> Add update check Closes #338 </s> remove version {dnsVersion} / address: {dnsAddress}:{dnsPort} </s> add <div className="nav-version__text"> version: <span className="nav-version__value">{dnsVersion}</span> </div> <div className="nav-version__text"> address: <span className="nav-version__value">{dnsAddress}:{dnsPort}</span> </div> </s> remove font-size: 0.9rem; </s> add font-size: 0.85rem;
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/src/components/App/index.js
getVersion: PropTypes.func,
<mask> isCoreRunning: PropTypes.bool, <mask> error: PropTypes.string, <mask> }; <mask> <mask> export default App; </s> Add update check Closes #338 </s> remove version {dnsVersion} / address: {dnsAddress}:{dnsPort} </s> add <div className="nav-version__text"> version: <span className="nav-version__value">{dnsVersion}</span> </div> <div className="nav-version__text"> address: <span className="nav-version__value">{dnsAddress}:{dnsPort}</span> </div>
[ "keep", "add", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/src/components/App/index.js
padding: 7px 0; font-size: 0.80rem;
<mask> overflow: hidden; <mask> } <mask> <mask> .nav-version { <mask> padding: 16px 0; <mask> font-size: 0.85rem; <mask> text-align: right; <mask> } <mask> <mask> .header-brand-img { <mask> height: 26px; </s> Add update check Closes #338 </s> remove font-size: 0.9rem; </s> add font-size: 0.85rem;
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/src/components/Header/Header.css
.nav-version__value { font-weight: 600; }
<mask> font-size: 0.80rem; <mask> text-align: right; <mask> } <mask> <mask> .header-brand-img { <mask> height: 26px; <mask> } <mask> <mask> @media screen and (min-width: 992px) { </s> Add update check Closes #338 </s> remove padding: 16px 0; font-size: 0.85rem; </s> add padding: 7px 0; font-size: 0.80rem; </s> remove font-size: 0.9rem; </s> add font-size: 0.85rem;
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/src/components/Header/Header.css
font-size: 0.85rem;
<mask> } <mask> <mask> .nav-version { <mask> padding: 0; <mask> font-size: 0.9rem; <mask> } <mask> } <mask> <mask> .dns-status { <mask> padding: 0.35em 0.5em; </s> Add update check Closes #338 </s> remove padding: 16px 0; font-size: 0.85rem; </s> add padding: 7px 0; font-size: 0.80rem;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/src/components/Header/Header.css
<div className="nav-version__text"> version: <span className="nav-version__value">{dnsVersion}</span> </div> <div className="nav-version__text"> address: <span className="nav-version__value">{dnsAddress}:{dnsPort}</span> </div>
<mask> export default function Version(props) { <mask> const { dnsVersion, dnsAddress, dnsPort } = props; <mask> return ( <mask> <div className="nav-version"> <mask> version {dnsVersion} / address: {dnsAddress}:{dnsPort} <mask> </div> <mask> ); <mask> } <mask> <mask> Version.propTypes = { </s> Add update check Closes #338
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/src/components/Header/Version.js
import versionCompare from 'tiny-version-compare';
<mask> import { combineReducers } from 'redux'; <mask> import { handleActions } from 'redux-actions'; <mask> import { loadingBarReducer } from 'react-redux-loading-bar'; <mask> import nanoid from 'nanoid'; <mask> <mask> import * as actions from '../actions'; <mask> <mask> const settings = handleActions({ <mask> [actions.initSettingsRequest]: state => ({ ...state, processing: true }), </s> Add update check Closes #338
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/src/reducers/index.js
processingVersion: true,
<mask> processingTopStats: true, <mask> processingStats: true, <mask> logStatusProcessing: false, <mask> }); <mask> <mask> const queryLogs = handleActions({ <mask> [actions.getLogsRequest]: state => ({ ...state, getLogsProcessing: true }), <mask> [actions.getLogsFailure]: state => ({ ...state, getLogsProcessing: false }), <mask> [actions.getLogsSuccess]: (state, { payload }) => { </s> Add update check Closes #338
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/43fcf4117db0e1e26085a0cc20a574edc8bd6255
client/src/reducers/index.js
"dnscrypt": "DNSCrypt",
<mask> "custom_ip": "Custom IP", <mask> "blocking_ipv4": "Blocking IPv4", <mask> "blocking_ipv6": "Blocking IPv6", <mask> "dns_over_https": "DNS-over-HTTPS", <mask> "dns_over_tls": "DNS-over-TLS", <mask> "dns_over_quic": "DNS-over-QUIC", <mask> "client_id": "Client ID", <mask> "client_id_placeholder": "Enter client ID", <mask> "client_id_desc": "Different clients can be identified by a special client ID. <a>Here</a> you can learn more about how to identify clients.", </s> Pull request: 2662 dnscrypt logs Merge in DNS/adguard-home from 2662-dnscrypt-logs to master Closes #2662. Squashed commit of the following: commit 05f6742b5c73e1d150834965ae3a54ca06ef8e24 Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:58:08 2021 +0300 all: imp docs commit ee0b8c574c1cb5302a5ffb62d2fec4126509b2e8 Merge: aaa8c6b8 e64df20e Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:56:44 2021 +0300 Merge branch 'master' into 2662-dnscrypt-logs commit aaa8c6b8085679f4acd234527bd03cb0b2520b4f Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:38:49 2021 +0300 all: document changes commit 57b6a4d8e95e87d928274d095dc2004f1591d940 Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:36:22 2021 +0300 all: fix dnscrypt in logs </s> remove } </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/44168292d5f466b9e7cda271987f03363ab6d6a8
client/src/__locales/en.json
<mask> "port_53_faq_link": "Port 53 is often occupied by \"DNSStubListener\" or \"systemd-resolved\" services. Please read <0>this instruction</0> on how to resolve this.", <mask> "adg_will_drop_dns_queries": "AdGuard Home will be dropping all DNS queries from this client.", <mask> "client_not_in_allowed_clients": "The client is not allowed because it is not in the \"Allowed clients\" list.", <mask> "experimental": "Experimental" <mask> } </s> Pull request: 2662 dnscrypt logs Merge in DNS/adguard-home from 2662-dnscrypt-logs to master Closes #2662. Squashed commit of the following: commit 05f6742b5c73e1d150834965ae3a54ca06ef8e24 Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:58:08 2021 +0300 all: imp docs commit ee0b8c574c1cb5302a5ffb62d2fec4126509b2e8 Merge: aaa8c6b8 e64df20e Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:56:44 2021 +0300 Merge branch 'master' into 2662-dnscrypt-logs commit aaa8c6b8085679f4acd234527bd03cb0b2520b4f Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:38:49 2021 +0300 all: document changes commit 57b6a4d8e95e87d928274d095dc2004f1591d940 Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:36:22 2021 +0300 all: fix dnscrypt in logs
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/AdguardTeam/AdGuardHome/commit/44168292d5f466b9e7cda271987f03363ab6d6a8
client/src/__locales/en.json
}
<mask> "adg_will_drop_dns_queries": "AdGuard Home will be dropping all DNS queries from this client.", <mask> "client_not_in_allowed_clients": "The client is not allowed because it is not in the \"Allowed clients\" list.", <mask> "experimental": "Experimental" <mask> } </s> Pull request: 2662 dnscrypt logs Merge in DNS/adguard-home from 2662-dnscrypt-logs to master Closes #2662. Squashed commit of the following: commit 05f6742b5c73e1d150834965ae3a54ca06ef8e24 Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:58:08 2021 +0300 all: imp docs commit ee0b8c574c1cb5302a5ffb62d2fec4126509b2e8 Merge: aaa8c6b8 e64df20e Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:56:44 2021 +0300 Merge branch 'master' into 2662-dnscrypt-logs commit aaa8c6b8085679f4acd234527bd03cb0b2520b4f Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:38:49 2021 +0300 all: document changes commit 57b6a4d8e95e87d928274d095dc2004f1591d940 Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:36:22 2021 +0300 all: fix dnscrypt in logs </s> remove } </s> add
[ "keep", "keep", "keep", "add" ]
https://github.com/AdguardTeam/AdGuardHome/commit/44168292d5f466b9e7cda271987f03363ab6d6a8
client/src/__locales/en.json
dnscrypt: 'dnscrypt',
<mask> <mask> export const SCHEME_TO_PROTOCOL_MAP = { <mask> doh: 'dns_over_https', <mask> dot: 'dns_over_tls', <mask> doq: 'dns_over_quic', <mask> '': 'plain_dns', <mask> }; <mask> </s> Pull request: 2662 dnscrypt logs Merge in DNS/adguard-home from 2662-dnscrypt-logs to master Closes #2662. Squashed commit of the following: commit 05f6742b5c73e1d150834965ae3a54ca06ef8e24 Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:58:08 2021 +0300 all: imp docs commit ee0b8c574c1cb5302a5ffb62d2fec4126509b2e8 Merge: aaa8c6b8 e64df20e Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:56:44 2021 +0300 Merge branch 'master' into 2662-dnscrypt-logs commit aaa8c6b8085679f4acd234527bd03cb0b2520b4f Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:38:49 2021 +0300 all: document changes commit 57b6a4d8e95e87d928274d095dc2004f1591d940 Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:36:22 2021 +0300 all: fix dnscrypt in logs </s> remove } </s> add
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/44168292d5f466b9e7cda271987f03363ab6d6a8
client/src/helpers/constants.js
ClientProtoDNSCrypt,
<mask> ClientProtoDOH, <mask> ClientProtoDOQ, <mask> ClientProtoDOT, <mask> ClientProtoPlain: <mask> <mask> return cp, nil <mask> default: <mask> return "", fmt.Errorf("invalid client proto: %q", s) </s> Pull request: 2662 dnscrypt logs Merge in DNS/adguard-home from 2662-dnscrypt-logs to master Closes #2662. Squashed commit of the following: commit 05f6742b5c73e1d150834965ae3a54ca06ef8e24 Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:58:08 2021 +0300 all: imp docs commit ee0b8c574c1cb5302a5ffb62d2fec4126509b2e8 Merge: aaa8c6b8 e64df20e Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:56:44 2021 +0300 Merge branch 'master' into 2662-dnscrypt-logs commit aaa8c6b8085679f4acd234527bd03cb0b2520b4f Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:38:49 2021 +0300 all: document changes commit 57b6a4d8e95e87d928274d095dc2004f1591d940 Author: Ainar Garipov <[email protected]> Date: Thu Feb 11 12:36:22 2021 +0300 all: fix dnscrypt in logs </s> remove } </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/44168292d5f466b9e7cda271987f03363ab6d6a8
internal/querylog/qlog.go
s.conf.HTTPRegister(http.MethodGet, "/control/dns_info", s.handleGetConfig) s.conf.HTTPRegister(http.MethodPost, "/control/dns_config", s.handleSetConfig) s.conf.HTTPRegister(http.MethodPost, "/control/test_upstream_dns", s.handleTestUpstreamDNS)
<mask> s.ServeHTTP(w, r) <mask> } <mask> <mask> func (s *Server) registerHandlers() { <mask> s.conf.HTTPRegister("GET", "/control/dns_info", s.handleGetConfig) <mask> s.conf.HTTPRegister("POST", "/control/dns_config", s.handleSetConfig) <mask> s.conf.HTTPRegister("POST", "/control/test_upstream_dns", s.handleTestUpstreamDNS) <mask> <mask> s.conf.HTTPRegister("GET", "/control/access/list", s.handleAccessList) <mask> s.conf.HTTPRegister("POST", "/control/access/set", s.handleAccessSet) <mask> <mask> s.conf.HTTPRegister("", "/dns-query", s.handleDOH) </s> Pull request: all: imp http handlers, imp docs Merge in DNS/adguard-home from fix-openapi to master Squashed commit of the following: commit 0e7530472fb566e5cab73d178c8ec16e5ef11dcb Author: Ainar Garipov <[email protected]> Date: Wed Jan 13 17:02:06 2021 +0300 all: imp http handlers, imp docs </s> remove s.conf.HTTPRegister("GET", "/control/access/list", s.handleAccessList) s.conf.HTTPRegister("POST", "/control/access/set", s.handleAccessSet) </s> add s.conf.HTTPRegister(http.MethodGet, "/control/access/list", s.handleAccessList) s.conf.HTTPRegister(http.MethodPost, "/control/access/set", s.handleAccessSet) </s> remove func handleStatus(w http.ResponseWriter, r *http.Request) { </s> add func handleStatus(w http.ResponseWriter, _ *http.Request) { </s> remove return ensure("POST", handler) </s> add return ensure(http.MethodPost, handler) </s> remove if method == "POST" || method == "PUT" || method == "DELETE" { </s> add if method == http.MethodPost || method == http.MethodPut || method == http.MethodDelete { </s> remove Context.mux.Handle("/control/login", postInstallHandler(ensureHandler("POST", handleLogin))) httpRegister("GET", "/control/logout", handleLogout) </s> add Context.mux.Handle("/control/login", postInstallHandler(ensureHandler(http.MethodPost, handleLogin))) httpRegister(http.MethodGet, "/control/logout", handleLogout)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4474e9fcf9073af593df76b4844f4091c1c7946e
internal/dnsforward/http.go
s.conf.HTTPRegister(http.MethodGet, "/control/access/list", s.handleAccessList) s.conf.HTTPRegister(http.MethodPost, "/control/access/set", s.handleAccessSet)
<mask> s.conf.HTTPRegister("GET", "/control/dns_info", s.handleGetConfig) <mask> s.conf.HTTPRegister("POST", "/control/dns_config", s.handleSetConfig) <mask> s.conf.HTTPRegister("POST", "/control/test_upstream_dns", s.handleTestUpstreamDNS) <mask> <mask> s.conf.HTTPRegister("GET", "/control/access/list", s.handleAccessList) <mask> s.conf.HTTPRegister("POST", "/control/access/set", s.handleAccessSet) <mask> <mask> s.conf.HTTPRegister("", "/dns-query", s.handleDOH) <mask> } </s> Pull request: all: imp http handlers, imp docs Merge in DNS/adguard-home from fix-openapi to master Squashed commit of the following: commit 0e7530472fb566e5cab73d178c8ec16e5ef11dcb Author: Ainar Garipov <[email protected]> Date: Wed Jan 13 17:02:06 2021 +0300 all: imp http handlers, imp docs </s> remove s.conf.HTTPRegister("GET", "/control/dns_info", s.handleGetConfig) s.conf.HTTPRegister("POST", "/control/dns_config", s.handleSetConfig) s.conf.HTTPRegister("POST", "/control/test_upstream_dns", s.handleTestUpstreamDNS) </s> add s.conf.HTTPRegister(http.MethodGet, "/control/dns_info", s.handleGetConfig) s.conf.HTTPRegister(http.MethodPost, "/control/dns_config", s.handleSetConfig) s.conf.HTTPRegister(http.MethodPost, "/control/test_upstream_dns", s.handleTestUpstreamDNS) </s> remove return ensure("POST", handler) </s> add return ensure(http.MethodPost, handler) </s> remove func handleStatus(w http.ResponseWriter, r *http.Request) { </s> add func handleStatus(w http.ResponseWriter, _ *http.Request) { </s> remove r, _ := http.NewRequest("GET", "http://localhost/", nil) </s> add r, _ := http.NewRequest(http.MethodGet, "http://localhost/", nil) </s> remove return ensure("GET", handler) </s> add return ensure(http.MethodGet, handler)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4474e9fcf9073af593df76b4844f4091c1c7946e
internal/dnsforward/http.go
Context.mux.Handle("/control/login", postInstallHandler(ensureHandler(http.MethodPost, handleLogin))) httpRegister(http.MethodGet, "/control/logout", handleLogout)
<mask> } <mask> <mask> // RegisterAuthHandlers - register handlers <mask> func RegisterAuthHandlers() { <mask> Context.mux.Handle("/control/login", postInstallHandler(ensureHandler("POST", handleLogin))) <mask> httpRegister("GET", "/control/logout", handleLogout) <mask> } <mask> <mask> func parseCookie(cookie string) string { <mask> pairs := strings.Split(cookie, ";") <mask> for _, pair := range pairs { </s> Pull request: all: imp http handlers, imp docs Merge in DNS/adguard-home from fix-openapi to master Squashed commit of the following: commit 0e7530472fb566e5cab73d178c8ec16e5ef11dcb Author: Ainar Garipov <[email protected]> Date: Wed Jan 13 17:02:06 2021 +0300 all: imp http handlers, imp docs </s> remove func handleStatus(w http.ResponseWriter, r *http.Request) { </s> add func handleStatus(w http.ResponseWriter, _ *http.Request) { </s> remove return ensure("POST", handler) </s> add return ensure(http.MethodPost, handler) </s> remove return ensure("GET", handler) </s> add return ensure(http.MethodGet, handler) </s> remove r, _ := http.NewRequest("GET", "http://localhost/", nil) </s> add r, _ := http.NewRequest(http.MethodGet, "http://localhost/", nil) </s> remove r.Method = "GET" </s> add r.Method = http.MethodGet
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4474e9fcf9073af593df76b4844f4091c1c7946e
internal/home/auth.go
r.Method = http.MethodGet
<mask> w := testResponseWriter{} <mask> w.hdr = make(http.Header) <mask> r := http.Request{} <mask> r.Header = make(http.Header) <mask> r.Method = "GET" <mask> <mask> // get / - we're redirected to login page <mask> r.URL = &url.URL{Path: "/"} <mask> handlerCalled = false <mask> handler2(&w, &r) </s> Pull request: all: imp http handlers, imp docs Merge in DNS/adguard-home from fix-openapi to master Squashed commit of the following: commit 0e7530472fb566e5cab73d178c8ec16e5ef11dcb Author: Ainar Garipov <[email protected]> Date: Wed Jan 13 17:02:06 2021 +0300 all: imp http handlers, imp docs </s> remove r, _ := http.NewRequest("GET", "http://localhost/", nil) </s> add r, _ := http.NewRequest(http.MethodGet, "http://localhost/", nil) </s> remove func handleStatus(w http.ResponseWriter, r *http.Request) { </s> add func handleStatus(w http.ResponseWriter, _ *http.Request) { </s> remove Context.mux.Handle("/control/login", postInstallHandler(ensureHandler("POST", handleLogin))) httpRegister("GET", "/control/logout", handleLogout) </s> add Context.mux.Handle("/control/login", postInstallHandler(ensureHandler(http.MethodPost, handleLogin))) httpRegister(http.MethodGet, "/control/logout", handleLogout) </s> remove 'example': '' </s> add </s> remove return ensure("GET", handler) </s> add return ensure(http.MethodGet, handler)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4474e9fcf9073af593df76b4844f4091c1c7946e
internal/home/auth_test.go
r, _ := http.NewRequest(http.MethodGet, "http://localhost/", nil)
<mask> } else { <mask> binary.BigEndian.PutUint32(data, tval) <mask> } <mask> assert.Nil(t, ioutil.WriteFile(glFilePrefix+"test", data, 0o644)) <mask> r, _ := http.NewRequest("GET", "http://localhost/", nil) <mask> r.AddCookie(&http.Cookie{Name: glCookieName, Value: "test"}) <mask> assert.True(t, glProcessCookie(r)) <mask> GLMode = false <mask> } </s> Pull request: all: imp http handlers, imp docs Merge in DNS/adguard-home from fix-openapi to master Squashed commit of the following: commit 0e7530472fb566e5cab73d178c8ec16e5ef11dcb Author: Ainar Garipov <[email protected]> Date: Wed Jan 13 17:02:06 2021 +0300 all: imp http handlers, imp docs </s> remove func handleStatus(w http.ResponseWriter, r *http.Request) { </s> add func handleStatus(w http.ResponseWriter, _ *http.Request) { </s> remove r.Method = "GET" </s> add r.Method = http.MethodGet </s> remove Context.mux.Handle("/control/login", postInstallHandler(ensureHandler("POST", handleLogin))) httpRegister("GET", "/control/logout", handleLogout) </s> add Context.mux.Handle("/control/login", postInstallHandler(ensureHandler(http.MethodPost, handleLogin))) httpRegister(http.MethodGet, "/control/logout", handleLogout) </s> remove return ensure("POST", handler) </s> add return ensure(http.MethodPost, handler) </s> remove return ensure("GET", handler) </s> add return ensure(http.MethodGet, handler)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4474e9fcf9073af593df76b4844f4091c1c7946e
internal/home/authglinet_test.go
func handleStatus(w http.ResponseWriter, _ *http.Request) {
<mask> } <mask> *dnsAddresses = append(*dnsAddresses, addr) <mask> } <mask> <mask> func handleStatus(w http.ResponseWriter, r *http.Request) { <mask> c := dnsforward.FilteringConfig{} <mask> if Context.dnsServer != nil { <mask> Context.dnsServer.WriteDiskConfig(&c) <mask> } <mask> </s> Pull request: all: imp http handlers, imp docs Merge in DNS/adguard-home from fix-openapi to master Squashed commit of the following: commit 0e7530472fb566e5cab73d178c8ec16e5ef11dcb Author: Ainar Garipov <[email protected]> Date: Wed Jan 13 17:02:06 2021 +0300 all: imp http handlers, imp docs </s> remove return ensure("POST", handler) </s> add return ensure(http.MethodPost, handler) </s> remove Context.mux.Handle("/control/login", postInstallHandler(ensureHandler("POST", handleLogin))) httpRegister("GET", "/control/logout", handleLogout) </s> add Context.mux.Handle("/control/login", postInstallHandler(ensureHandler(http.MethodPost, handleLogin))) httpRegister(http.MethodGet, "/control/logout", handleLogout) </s> remove return ensure("GET", handler) </s> add return ensure(http.MethodGet, handler) </s> remove r, _ := http.NewRequest("GET", "http://localhost/", nil) </s> add r, _ := http.NewRequest(http.MethodGet, "http://localhost/", nil) </s> remove r.Method = "GET" </s> add r.Method = http.MethodGet
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4474e9fcf9073af593df76b4844f4091c1c7946e
internal/home/control.go
if method == http.MethodPost || method == http.MethodPut || method == http.MethodDelete {
<mask> http.Error(w, "This request must be "+method, http.StatusMethodNotAllowed) <mask> return <mask> } <mask> <mask> if method == "POST" || method == "PUT" || method == "DELETE" { <mask> Context.controlLock.Lock() <mask> defer Context.controlLock.Unlock() <mask> } <mask> <mask> handler(w, r) </s> Pull request: all: imp http handlers, imp docs Merge in DNS/adguard-home from fix-openapi to master Squashed commit of the following: commit 0e7530472fb566e5cab73d178c8ec16e5ef11dcb Author: Ainar Garipov <[email protected]> Date: Wed Jan 13 17:02:06 2021 +0300 all: imp http handlers, imp docs </s> remove return ensure("POST", handler) </s> add return ensure(http.MethodPost, handler) </s> remove return ensure("GET", handler) </s> add return ensure(http.MethodGet, handler) </s> remove func handleStatus(w http.ResponseWriter, r *http.Request) { </s> add func handleStatus(w http.ResponseWriter, _ *http.Request) { </s> remove s.conf.HTTPRegister("GET", "/control/dns_info", s.handleGetConfig) s.conf.HTTPRegister("POST", "/control/dns_config", s.handleSetConfig) s.conf.HTTPRegister("POST", "/control/test_upstream_dns", s.handleTestUpstreamDNS) </s> add s.conf.HTTPRegister(http.MethodGet, "/control/dns_info", s.handleGetConfig) s.conf.HTTPRegister(http.MethodPost, "/control/dns_config", s.handleSetConfig) s.conf.HTTPRegister(http.MethodPost, "/control/test_upstream_dns", s.handleTestUpstreamDNS) </s> remove 'example': '' </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4474e9fcf9073af593df76b4844f4091c1c7946e
internal/home/control.go