Skip to content

Commit

Permalink
all: fixed goroutine leak
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Nov 25, 2024
1 parent d4ca148 commit 3027fc4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions internal/dnsforward/dnsforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 3027fc4

Please sign in to comment.