Pull request 2310: 6818-fix-goroutine-leak

Updates #6818.

Squashed commit of the following:

commit 3027fc4a61
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Mon Nov 25 16:53:33 2024 +0300

    all: fixed goroutine leak
This commit is contained in:
Stanislav Chzhen 2024-11-26 13:34:16 +03:00
parent d4ca14806e
commit d578c713ff
2 changed files with 15 additions and 6 deletions

View File

@ -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

View File

@ -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