From 5f8ec340eb73cac72720d20dc9a5439aa1a7812e Mon Sep 17 00:00:00 2001 From: Henry Harrington Date: Sat, 24 Jan 2015 17:52:05 +0000 Subject: [PATCH] Retry sending DNS packets when no response is received. --- net/ethernet.lisp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/net/ethernet.lisp b/net/ethernet.lisp index 3b9cfbae6..b8176ea2b 100644 --- a/net/ethernet.lisp +++ b/net/ethernet.lisp @@ -1333,20 +1333,21 @@ the seperator character." (reverse additional-records))))) (defun dns-request (domain) - (dolist (server *dns-servers*) - (let ((id (random (expt 2 16)))) - (with-udp-connection (conn server +dns-port+) - (send (build-dns-packet id +dns-standard-query+ - :questions `((,domain :a :in))) - conn) - (let ((response (receive conn 15))) - (when response - (multiple-value-bind (rx-id flags questions answers authority-rrs additional-rrs) - (decode-dns-packet response) - (when (eql rx-id id) - (dolist (a answers) - (when (eql (second a) :a) - (return-from dns-request (fifth a)))))))))))) + (dotimes (i 3) ; UDP is unreliable. + (dolist (server *dns-servers*) + (let ((id (random (expt 2 16)))) + (with-udp-connection (conn server +dns-port+) + (send (build-dns-packet id +dns-standard-query+ + :questions `((,domain :a :in))) + conn) + (let ((response (receive conn 10))) + (when response + (multiple-value-bind (rx-id flags questions answers authority-rrs additional-rrs) + (decode-dns-packet response) + (when (eql rx-id id) + (dolist (a answers) + (when (eql (second a) :a) + (return-from dns-request (fifth a))))))))))))) ;;; High-level address resolution.