Remove mutex lock during call dns.ResponseWriter.WriteMsg

Write io buffer needn't mutex operation.
Refere to kenshinx/godns#1
This commit is contained in:
kenshinx 2015-02-12 16:06:09 +08:00
parent 8e504da15a
commit ef7d8f8fa2
1 changed files with 1 additions and 4 deletions

View File

@ -27,7 +27,6 @@ type GODNSHandler struct {
resolver *Resolver
cache Cache
hosts Hosts
mu *sync.Mutex
}
func NewHandler() *GODNSHandler {
@ -73,7 +72,7 @@ func NewHandler() *GODNSHandler {
hosts := NewHosts(settings.Hosts, settings.Redis)
return &GODNSHandler{resolver, cache, hosts, new(sync.Mutex)}
return &GODNSHandler{resolver, cache, hosts}
}
func (h *GODNSHandler) do(Net string, w dns.ResponseWriter, req *dns.Msg) {
@ -127,10 +126,8 @@ func (h *GODNSHandler) do(Net string, w dns.ResponseWriter, req *dns.Msg) {
Debug("%s didn't hit cache: %s", Q.String(), err)
} else {
Debug("%s hit cache", Q.String())
h.mu.Lock()
mesg.Id = req.Id
w.WriteMsg(mesg)
h.mu.Unlock()
return
}
}