- DNS: didn't process requests while updating filters

#2043

Squashed commit of the following:

commit cf430fed46ead2de4cd89f1adef40874b4a35536
Merge: 9fb44ef3 d23acd20
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Wed Aug 26 18:39:23 2020 +0300

    Merge remote-tracking branch 'origin/master' into 2043-optimize

commit 9fb44ef3a50044f043620e35b65b659ca8080e1f
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Wed Aug 26 15:39:07 2020 +0300

    - DNS: didn't process requests while updating filters
This commit is contained in:
Simon Zolin 2020-08-26 18:58:21 +03:00
parent d23acd2016
commit 98b6eb320f
1 changed files with 4 additions and 3 deletions

View File

@ -532,9 +532,6 @@ func createFilteringEngine(filters []Filter) (*filterlist.RuleStorage, *urlfilte
// Initialize urlfilter objects // Initialize urlfilter objects
func (d *Dnsfilter) initFiltering(allowFilters, blockFilters []Filter) error { func (d *Dnsfilter) initFiltering(allowFilters, blockFilters []Filter) error {
d.engineLock.Lock()
defer d.engineLock.Unlock()
d.reset()
rulesStorage, filteringEngine, err := createFilteringEngine(blockFilters) rulesStorage, filteringEngine, err := createFilteringEngine(blockFilters)
if err != nil { if err != nil {
return err return err
@ -543,10 +540,14 @@ func (d *Dnsfilter) initFiltering(allowFilters, blockFilters []Filter) error {
if err != nil { if err != nil {
return err return err
} }
d.engineLock.Lock()
d.reset()
d.rulesStorage = rulesStorage d.rulesStorage = rulesStorage
d.filteringEngine = filteringEngine d.filteringEngine = filteringEngine
d.rulesStorageWhite = rulesStorageWhite d.rulesStorageWhite = rulesStorageWhite
d.filteringEngineWhite = filteringEngineWhite d.filteringEngineWhite = filteringEngineWhite
d.engineLock.Unlock()
// Make sure that the OS reclaims memory as soon as possible // Make sure that the OS reclaims memory as soon as possible
debug.FreeOSMemory() debug.FreeOSMemory()