[gnus git] branch master updated: m0-9-6-g4bb0647 =1= Flush dns.el data if the network interfaces change

Lars Ingebrigtsen <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  4bb0647c56e3f8d30dc1d311ce7864a09de4de9b (commit)
      from  620f7dd653e097f1b7b088d5c9c5cecd5e81df64 (commit)


- Log -----------------------------------------------------------------
commit 4bb0647c56e3f8d30dc1d311ce7864a09de4de9b
Author: Magnus Henoch <[email protected]>
Date:   Fri Jan 31 15:52:02 2014 -0800

    Flush dns.el data if the network interfaces change
    
    * dns.el (dns-servers-up-to-date-p): New function to see whether the
    network interfaces changed.
    (dns-query): Use it to flush the data.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b0814fb..0a6a95b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2014-01-31  Magnus Henoch  <[email protected]>
+
+	* dns.el (dns-servers-up-to-date-p): New function to see whether the
+	network interfaces changed.
+	(dns-query): Use it to flush the data.
+
 2013-09-04  Rasmus Pank Roulund  <[email protected]>
 
 	* gnus-fun.el (gnus-x-face-omit-files): Regexp to omit matched results
diff --git a/lisp/dns.el b/lisp/dns.el
index e52ead1..1419350 100644
--- a/lisp/dns.el
+++ b/lisp/dns.el
@@ -31,6 +31,12 @@
   "List of DNS servers to query.
 If nil, /etc/resolv.conf and nslookup will be consulted.")
 
+(defvar dns-servers-valid-for-interfaces nil
+  "The return value of `network-interface-list' when `dns-servers' was set.
+If the set of network interfaces and/or their IP addresses
+change, then presumably the list of DNS servers needs to be
+updated.  Set this variable to t to disable the check.")
+
 ;;; Internal code:
 
 (defvar dns-query-types
@@ -297,6 +303,15 @@ If TCP-P, the first two bytes of the package with be the length field."
            (t string)))
       (goto-char point))))
 
+(defun dns-servers-up-to-date-p ()
+  "Return false if we need to recheck the list of DNS servers."
+  (and dns-servers
+       (or (eq dns-servers-valid-for-interfaces t)
+	   ;; `network-interface-list' was introduced in Emacs 22.1.
+	   (not (fboundp 'network-interface-list))
+	   (equal dns-servers-valid-for-interfaces
+		  (network-interface-list)))))
+
 (defun dns-set-servers ()
   "Set `dns-servers' to a list of DNS servers or nil if none are found.
 Parses \"/etc/resolv.conf\" or calls \"nslookup\"."
@@ -314,7 +329,9 @@ Parses \"/etc/resolv.conf\" or calls \"nslookup\"."
 	  (goto-char (point-min))
 	  (re-search-forward
 	   "^Address:[ \t]*\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" nil t)
-	  (setq dns-servers (list (match-string 1)))))))
+	  (setq dns-servers (list (match-string 1))))))
+  (when (fboundp 'network-interface-list)
+    (setq dns-servers-valid-for-interfaces (network-interface-list))))
 
 (defun dns-read-txt (string)
   (if (> (length string) 1)
@@ -378,7 +395,7 @@ Parses \"/etc/resolv.conf\" or calls \"nslookup\"."
 If FULLP, return the entire record returned.
 If REVERSEP, look up an IP address."
   (setq type (or type 'A))
-  (unless dns-servers
+  (unless (dns-servers-up-to-date-p)
     (dns-set-servers))
 
   (when reversep

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog |    6 ++++++
 lisp/dns.el    |   21 +++++++++++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.