Cleanup the defer from serve()

Close the connection when returning.
This commit is contained in:
Miek Gieben 2013-10-16 21:45:29 +01:00
parent 075c815ff1
commit 145242b519
1 changed files with 3 additions and 8 deletions

View File

@ -381,17 +381,14 @@ func (srv *Server) serveUDP(l *net.UDPConn) error {
// Serve a new connection.
func serve(a net.Addr, h Handler, m []byte, u *net.UDPConn, t *net.TCPConn, tsigSecret map[string]string) {
// Request has been read in serveUDP or serveTCP
w := new(response)
w.tsigSecret = tsigSecret
w.udp = u
w.tcp = t
w.remoteAddr = a
w := &response{tsigSecret: tsigSecret, udp: u, tcp: t, remoteAddr: a}
req := new(Msg)
if req.Unpack(m) != nil {
// Send a format error back
x := new(Msg)
x.SetRcodeFormatError(req)
w.WriteMsg(x)
w.Close()
return
}
defer func() {
@ -399,9 +396,7 @@ func serve(a net.Addr, h Handler, m []byte, u *net.UDPConn, t *net.TCPConn, tsig
// client takes care of the connection, i.e. calls Close()
return
}
if t != nil {
w.Close()
}
w.Close()
}()
w.tsigStatus = nil