Make MaxTCPQueries configurable (#673)
This commit is contained in:
parent
77d95a53d0
commit
621df0907e
12
server.go
12
server.go
|
@ -13,7 +13,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Maximum number of TCP queries before we close the socket.
|
// Default maximum number of TCP queries before we close the socket.
|
||||||
const maxTCPQueries = 128
|
const maxTCPQueries = 128
|
||||||
|
|
||||||
// Interval for stop worker if no load
|
// Interval for stop worker if no load
|
||||||
|
@ -303,6 +303,8 @@ type Server struct {
|
||||||
DecorateReader DecorateReader
|
DecorateReader DecorateReader
|
||||||
// DecorateWriter is optional, allows customization of the process that writes raw DNS messages.
|
// DecorateWriter is optional, allows customization of the process that writes raw DNS messages.
|
||||||
DecorateWriter DecorateWriter
|
DecorateWriter DecorateWriter
|
||||||
|
// Maximum number of TCP queries before we close the socket. Default is maxTCPQueries (unlimited if -1).
|
||||||
|
MaxTCPQueries int
|
||||||
|
|
||||||
// UDP packet or TCP connection queue
|
// UDP packet or TCP connection queue
|
||||||
queue chan *response
|
queue chan *response
|
||||||
|
@ -593,8 +595,12 @@ func (srv *Server) serve(w *response) {
|
||||||
|
|
||||||
timeout := srv.getReadTimeout()
|
timeout := srv.getReadTimeout()
|
||||||
|
|
||||||
// TODO(miek): make maxTCPQueries configurable?
|
limit := srv.MaxTCPQueries
|
||||||
for q := 0; q < maxTCPQueries; q++ {
|
if limit == 0 {
|
||||||
|
limit = maxTCPQueries
|
||||||
|
}
|
||||||
|
|
||||||
|
for q := 0; q < limit || limit == -1; q++ {
|
||||||
var err error
|
var err error
|
||||||
w.msg, err = reader.ReadTCP(w.tcp, timeout)
|
w.msg, err = reader.ReadTCP(w.tcp, timeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue