cache contents of resolv.conf
This commit is contained in:
parent
f0dbc7acba
commit
e7aa14ee73
|
@ -1067,8 +1067,19 @@
|
||||||
'()
|
'()
|
||||||
rest-of-line))
|
rest-of-line))
|
||||||
|
|
||||||
;; TODO: cache result
|
(define *resolv.conf-cache*)
|
||||||
|
(define *resolv.conf-cache-date* 0)
|
||||||
|
|
||||||
(define (parse-resolv.conf)
|
(define (parse-resolv.conf)
|
||||||
|
(let ((actual-m-time (file-info:mtime (file-info "/etc/resolv.conf"))))
|
||||||
|
(if (> actual-m-time *resolv.conf-cache-date*)
|
||||||
|
(let ((contents (really-parse-resolv.conf "/etc/resolv.conf")))
|
||||||
|
(set! *resolv.conf-cache* contents)
|
||||||
|
(set! *resolv.conf-cache-date* actual-m-time)
|
||||||
|
contents)
|
||||||
|
*resolv.conf-cache*)))
|
||||||
|
|
||||||
|
(define (really-parse-resolv.conf file-name)
|
||||||
|
|
||||||
;; accumulate nameserver entries
|
;; accumulate nameserver entries
|
||||||
;; domain and search are mutual exclusive, take the last
|
;; domain and search are mutual exclusive, take the last
|
||||||
|
@ -1101,7 +1112,7 @@
|
||||||
have-search-or-domain?
|
have-search-or-domain?
|
||||||
nameservers)))))
|
nameservers)))))
|
||||||
|
|
||||||
(with-input-from-file "/etc/resolv.conf"
|
(with-input-from-file file-name
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let loop ((rev-result '()))
|
(let loop ((rev-result '()))
|
||||||
(let ((l (read-line)))
|
(let ((l (read-line)))
|
||||||
|
|
Loading…
Reference in New Issue