summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2020-07-30 02:38:00 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2020-07-30 05:32:16 +0200
commit18a5e52eed67700b65681ce5007f121f9700f241 (patch)
treed4701ca523e21688fe9c4a96528afd0aa3f00b67
parent55806ee46b047c03698340ce8a6397de6355c56a (diff)
downloademacs-18a5e52eed67700b65681ce5007f121f9700f241.tar.gz
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.
-rw-r--r--lisp/net/dns.el60
1 files changed, 27 insertions, 33 deletions
diff --git a/lisp/net/dns.el b/lisp/net/dns.el
index 53ea0b19b52..e02c99ea0c3 100644
--- a/lisp/net/dns.el
+++ b/lisp/net/dns.el
@@ -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