mirror of
https://github.com/coredns/coredns.git
synced 2025-11-02 02:03:13 -05:00
middleware/proxy: add read/writeDeadline (#477)
Add deadline to break the connection. We use the default of 5 seconds. After this the backend is marked unhealthy and not used for some time. Fixes #467
This commit is contained in:
@@ -83,8 +83,14 @@ func (c *client) exchange(m *dns.Msg, co net.Conn) (dns.Msg, error) {
|
||||
|
||||
dnsco := &dns.Conn{Conn: co, UDPSize: udpsize}
|
||||
|
||||
writeDeadline := time.Now().Add(defaultTimeout)
|
||||
dnsco.SetWriteDeadline(writeDeadline)
|
||||
dnsco.WriteMsg(m)
|
||||
|
||||
readDeadline := time.Now().Add(defaultTimeout)
|
||||
co.SetReadDeadline(readDeadline)
|
||||
r, err := dnsco.ReadMsg()
|
||||
|
||||
dnsco.Close()
|
||||
if r == nil {
|
||||
return dns.Msg{}, err
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
package proxy
|
||||
|
||||
/* TODO */
|
||||
Reference in New Issue
Block a user