- 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

View File

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