Commit 18a5e52e authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

Small dns.el code cleanup

* lisp/net/dns.el (dns-query): Clean up code slightly by removing
a macro and moving the code into the function itself.
parent 55806ee4
......@@ -355,25 +355,6 @@ Parses \"/etc/resolv.conf\" or calls \"nslookup\"."
result))
;;; Interface functions.
(defmacro dns-make-network-process (server)
`(let ((server ,server)
(coding-system-for-read 'binary)
(coding-system-for-write 'binary))
(if (and
(fboundp 'make-network-process)
(featurep 'make-network-process '(:type datagram)))
(make-network-process
:name "dns"
:coding 'binary
:buffer (current-buffer)
:host server
:service "domain"
:type 'datagram)
;; Older versions of Emacs do not have `make-network-process',
;; and on MS-Windows datagram sockets are not supported, so we
;; fall back on opening a TCP connection to the DNS server.
(open-network-stream "dns" (current-buffer) server "domain"))))
(defvar dns-cache (make-vector 4096 0))
(defun dns-query-cached (name &optional type fullp reversep)
......@@ -386,9 +367,6 @@ Parses \"/etc/resolv.conf\" or calls \"nslookup\"."
(set (intern key dns-cache) result)
result))))
;; The old names `query-dns' and `query-dns-cached' weren't used in Emacs 23
;; yet, so no alias are provided. --rsteib
(defun dns-query (name &optional type fullp reversep)
"Query a DNS server for NAME of TYPE.
If FULLP, return the entire record returned.
......@@ -409,17 +387,33 @@ If REVERSEP, look up an IP address."
nil)
(with-temp-buffer
(set-buffer-multibyte nil)
(let* ((process (condition-case ()
(dns-make-network-process (car dns-servers))
(error
(message
"dns: Got an error while trying to talk to %s"
(car dns-servers))
nil)))
(step 100)
(times (* dns-timeout 1000))
(id (random 65000))
(tcp-p (and process (not (process-contact process :type)))))
(let* ((process
(condition-case ()
(let ((server (car dns-servers))
(coding-system-for-read 'binary)
(coding-system-for-write 'binary))
(if (featurep 'make-network-process '(:type datagram))
(make-network-process
:name "dns"
:coding 'binary
:buffer (current-buffer)
:host server
:service "domain"
:type 'datagram)
;; On MS-Windows datagram sockets are not
;; supported, so we fall back on opening a TCP
;; connection to the DNS server.
(open-network-stream "dns" (current-buffer)
server "domain")))
(error
(message
"dns: Got an error while trying to talk to %s"
(car dns-servers))
nil)))
(step 100)
(times (* dns-timeout 1000))
(id (random 65000))
(tcp-p (and process (not (process-contact process :type)))))
(when process
(process-send-string
process
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment