From 8a4d02c6e2d60e4d1f6cd1f9a3f3eee27b1c1c87 Mon Sep 17 00:00:00 2001 From: Tyler Date: Thu, 18 Aug 2022 23:43:58 -0400 Subject: [PATCH] Cleanup hosts map --- config.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index ff605dc..2d7be75 100644 --- a/config.go +++ b/config.go @@ -167,6 +167,8 @@ func (r *Redirector) reloadServers() error { hosts := make(map[string]bool) + var hostsLock sync.Mutex + for _, server := range r.config.ServerList { wg.Add(1) @@ -186,8 +188,6 @@ func (r *Redirector) reloadServers() error { return err } - hosts[u.Host] = true - i := -1 if v, exists := existing[u.Host]; exists { @@ -204,6 +204,10 @@ func (r *Redirector) reloadServers() error { return } + hostsLock.Lock() + hosts[u.Host] = true + hostsLock.Unlock() + if _, ok := existing[u.Host]; ok { s.Redirects = r.servers[i].Redirects