mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
server: small cleanups (#2740)
Rename connTimeout to graceTimeout to be more instructive on it's use, some whitespace for imports lines. Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/coredns/coredns/plugin/pkg/log"
|
"github.com/coredns/coredns/plugin/pkg/log"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ type Server struct {
|
|||||||
server [2]*dns.Server // 0 is a net.Listener, 1 is a net.PacketConn (a *UDPConn) in our case.
|
server [2]*dns.Server // 0 is a net.Listener, 1 is a net.PacketConn (a *UDPConn) in our case.
|
||||||
m sync.Mutex // protects the servers
|
m sync.Mutex // protects the servers
|
||||||
|
|
||||||
zones map[string]*Config // zones keyed by their address
|
zones map[string]*Config // zones keyed by their address
|
||||||
dnsWg sync.WaitGroup // used to wait on outstanding connections
|
dnsWg sync.WaitGroup // used to wait on outstanding connections
|
||||||
connTimeout time.Duration // the maximum duration of a graceful shutdown
|
graceTimeout time.Duration // the maximum duration of a graceful shutdown
|
||||||
trace trace.Trace // the trace plugin for the server
|
trace trace.Trace // the trace plugin for the server
|
||||||
debug bool // disable recover()
|
debug bool // disable recover()
|
||||||
classChaos bool // allow non-INET class queries
|
classChaos bool // allow non-INET class queries
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServer returns a new CoreDNS server and compiles all plugins in to it. By default CH class
|
// NewServer returns a new CoreDNS server and compiles all plugins in to it. By default CH class
|
||||||
@@ -46,9 +46,9 @@ type Server struct {
|
|||||||
func NewServer(addr string, group []*Config) (*Server, error) {
|
func NewServer(addr string, group []*Config) (*Server, error) {
|
||||||
|
|
||||||
s := &Server{
|
s := &Server{
|
||||||
Addr: addr,
|
Addr: addr,
|
||||||
zones: make(map[string]*Config),
|
zones: make(map[string]*Config),
|
||||||
connTimeout: 5 * time.Second, // TODO(miek): was configurable
|
graceTimeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have to bound our wg with one increment
|
// We have to bound our wg with one increment
|
||||||
@@ -163,7 +163,7 @@ func (s *Server) Stop() (err error) {
|
|||||||
// Wait for remaining connections to finish or
|
// Wait for remaining connections to finish or
|
||||||
// force them all to close after timeout
|
// force them all to close after timeout
|
||||||
select {
|
select {
|
||||||
case <-time.After(s.connTimeout):
|
case <-time.After(s.graceTimeout):
|
||||||
case <-done:
|
case <-done:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user