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:
Miek Gieben
2017-01-11 21:23:57 +00:00
committed by GitHub
parent 0ee88d3007
commit 0c3ad499d8
3 changed files with 49 additions and 3 deletions

View File

@@ -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