cache contents of resolv.conf

This commit is contained in:
mainzelm 2002-12-22 13:45:38 +00:00
parent f0dbc7acba
commit e7aa14ee73
1 changed files with 13 additions and 2 deletions

View File

@ -1067,8 +1067,19 @@
'()
rest-of-line))
;; TODO: cache result
(define *resolv.conf-cache*)
(define *resolv.conf-cache-date* 0)
(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
;; domain and search are mutual exclusive, take the last
@ -1101,7 +1112,7 @@
have-search-or-domain?
nameservers)))))
(with-input-from-file "/etc/resolv.conf"
(with-input-from-file file-name
(lambda ()
(let loop ((rev-result '()))
(let ((l (read-line)))