From 98b6eb320f951fca5d3588cb037a6df741d8fecd Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Wed, 26 Aug 2020 18:58:21 +0300 Subject: [PATCH] - DNS: didn't process requests while updating filters #2043 Squashed commit of the following: commit cf430fed46ead2de4cd89f1adef40874b4a35536 Merge: 9fb44ef3 d23acd20 Author: Simon Zolin Date: Wed Aug 26 18:39:23 2020 +0300 Merge remote-tracking branch 'origin/master' into 2043-optimize commit 9fb44ef3a50044f043620e35b65b659ca8080e1f Author: Simon Zolin Date: Wed Aug 26 15:39:07 2020 +0300 - DNS: didn't process requests while updating filters --- dnsfilter/dnsfilter.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dnsfilter/dnsfilter.go b/dnsfilter/dnsfilter.go index 71c73b1f..30cd2fee 100644 --- a/dnsfilter/dnsfilter.go +++ b/dnsfilter/dnsfilter.go @@ -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()