Split part of DNSServer.Start() to a separate ActivateAndServe()
Specifically, move the part that blocks, and call that as necessary. This means Start() can run on the caller's goroutine and avoid race conditions.
This commit is contained in:
1 parent
1b57a24789
commit
9636675c2c
4 files changed
+19
-6
No files matched your search
@@ -218,7 +218,10 @@ func (s *DNSServer) Start() error {
|
||||
s.tcpSrv = &dns.Server{Listener: l, Handler: s.createMux(protTCP), ReadTimeout: s.readTimeout}
|
||||
|
||||
s.listenersWg.Add(2)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *DNSServer) ActivateAndServe() {
|
||||
go func() {
|
||||
defer s.listenersWg.Done()
|
||||
|
||||
@@ -241,7 +244,6 @@ func (s *DNSServer) Start() error {
|
||||
s.listenersWg.Wait()
|
||||
|
||||
Info.Printf("[dns] Server exiting...")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Return status string
|
||||
|
||||
Reference in new issue
Block a user