mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04: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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user