prevent leaks when reloading domains lists in debug

If the log level was debug, when reloading the lists of domains could
lead to memory leaks.
This commit is contained in:
Gustavo Iñiguez Goia 2021-03-21 21:16:57 +01:00
parent 7cd16c6f3d
commit 36cdb76113

View file

@ -86,6 +86,9 @@ Exit:
// ClearLists deletes all the entries of a list
func (o *Operator) ClearLists() {
o.Lock()
defer o.Unlock()
log.Info("clearing domains lists: %d - %s", len(o.lists), o.Data)
for k := range o.lists {
delete(o.lists, k)
@ -132,9 +135,7 @@ func (o *Operator) readList(fileName string) (dups uint64) {
dups++
continue
}
o.Lock()
o.lists[host] = fileName
o.Unlock()
}
raw = nil
lines = nil
@ -149,8 +150,8 @@ func (o *Operator) readLists() error {
var dups uint64
// this list is particular to this operator and rule
o.Lock()
defer o.Unlock()
o.lists = make(map[string]string)
o.Unlock()
expr := filepath.Join(o.Data, "*.*")
fileList, err := filepath.Glob(expr)