Browse Source

handle requests in a goroutine

master
Brett Langdon 10 years ago
parent
commit
849165ef02
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      server.go

+ 10
- 0
server.go View File

@ -43,6 +43,16 @@ func (s *Server) ListenAndServe() error {
// ServeDNS will be called for every DNS request to this server.
// It will attempt to provide answers to all questions from the configured zone.
func (s *Server) ServeDNS(w dns.ResponseWriter, request *dns.Msg) {
// Call `Hijack` since we will handle closing `dns.ResponseWriter` ourselves
w.Hijack()
// Handle the request
go s.handle(w, request)
}
func (s *Server) handle(w dns.ResponseWriter, request *dns.Msg) {
// Always close the writer
defer w.Close()
// Capture starting time for measuring message response time
var start time.Time
start = time.Now()


Loading…
Cancel
Save