mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
[plugin/proxy]: Return on WriteMsg err. (#2096)
* [plugin/proxy]: Return on WriteMsg err. Followup PR on the heels of #2050. Short-circut and log on error from `WriteMsg`. This will prevent code getting stuck on `ReadMsg` and allow for easier debugging. Also simply the `ReadMsg` calling code a little - remove double `Close` (already called above).
This commit is contained in:
@@ -89,15 +89,12 @@ func exchange(m *dns.Msg, co net.Conn) (*dns.Msg, error) {
|
||||
|
||||
writeDeadline := time.Now().Add(defaultTimeout)
|
||||
dnsco.SetWriteDeadline(writeDeadline)
|
||||
dnsco.WriteMsg(m)
|
||||
if err := dnsco.WriteMsg(m); err != nil {
|
||||
log.Debugf("Failed to send message: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
readDeadline := time.Now().Add(defaultTimeout)
|
||||
co.SetReadDeadline(readDeadline)
|
||||
r, err := dnsco.ReadMsg()
|
||||
|
||||
dnsco.Close()
|
||||
if r == nil {
|
||||
return nil, err
|
||||
}
|
||||
return r, err
|
||||
return dnsco.ReadMsg()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user