diff --git a/CHANGELOG.md b/CHANGELOG.md index b260d138..52053e9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,12 @@ NOTE: Add new changes BELOW THIS COMMENT. permissions for the security-sensitive files and directories, which caused issues on Windows ([#7400]). +### Fixed + +- Goroutine leak during configuration update resulting in increased response + time. ([#6818]). + +[#6818]: https://github.com/AdguardTeam/AdGuardHome/issues/6818 [#7400]: https://github.com/AdguardTeam/AdGuardHome/issues/7400 [go-1.23.3]: https://groups.google.com/g/golang-announce/c/X5KodEJYuqI diff --git a/internal/dnsforward/dnsforward.go b/internal/dnsforward/dnsforward.go index 107eea39..27037234 100644 --- a/internal/dnsforward/dnsforward.go +++ b/internal/dnsforward/dnsforward.go @@ -818,6 +818,8 @@ func (s *Server) proxy() (p *proxy.Proxy) { } // Reconfigure applies the new configuration to the DNS server. +// +// TODO(a.garipov): This whole piece of API is weird and needs to be remade. func (s *Server) Reconfigure(conf *ServerConfig) error { s.serverLock.Lock() defer s.serverLock.Unlock() @@ -831,14 +833,15 @@ func (s *Server) Reconfigure(conf *ServerConfig) error { // We wait for some time and hope that this fd will be closed. time.Sleep(100 * time.Millisecond) - // TODO(a.garipov): This whole piece of API is weird and needs to be remade. + if s.addrProc != nil { + err := s.addrProc.Close() + if err != nil { + log.Error("dnsforward: closing address processor: %s", err) + } + } + if conf == nil { conf = &s.conf - } else { - closeErr := s.addrProc.Close() - if closeErr != nil { - log.Error("dnsforward: closing address processor: %s", closeErr) - } } // TODO(e.burkov): It seems an error here brings the server down, which is