From efab1a31610824997037448bb1cd917edfddbb20 Mon Sep 17 00:00:00 2001 From: cresh Date: Tue, 23 Jul 2002 08:48:47 +0000 Subject: [PATCH] concurrent lookup changes --- scheme/lib/dns.scm | 27 +++++++++++++++------------ scheme/packages.scm | 1 - 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/scheme/lib/dns.scm b/scheme/lib/dns.scm index 9a918ce..19045ec 100644 --- a/scheme/lib/dns.scm +++ b/scheme/lib/dns.scm @@ -41,9 +41,12 @@ ; dns-lookup-ip can either be given an ip-string or an ip-address32. ; ; concurrent dns lookup: -; a concurrent lookup to all nameservers in /etc/resolv.conf is started, -; if the variable dns-concurrent-lookup is given as optional -; argument. +; if a list of nameservers is given to the optional argument, +; a concurrent lookup to all nameservers in this list is started. +; The nameservers in this list could either be ip-strings or ip-address32s. +; example: (dns-lookup-name "www.uni-tuebingen.de" (dns-find-nameserver-list)) +; starts an concurrent lookup which contacts all nameservers in +; /etc/resolv.conf. ; ; ; (dns-lookup [nameserver]) @@ -163,11 +166,7 @@ (else (more)))) -;; concurrent-flag -(define dns-concurrent-lookup 'dns-concurrent-lookup) - ;;; -- globals and types - ;; off (define *nul* (ascii->char 0)) @@ -997,11 +996,15 @@ ;; concurrent-lookup ;; starts a -lookup to all nameservers in (dns-find-nameserver-list) -(define (concurrent-lookup lookup name) +(define (concurrent-lookup lookup name nameservers) (let* ((return 'no-value) (lock (make-lock)) (queue (make-queue)) - (nameserver-list (dns-find-nameserver-list))) + (nameserver-list (map (lambda (nameserver) + (if (address32? nameserver) + (address32->ip-string nameserver) + nameserver)) + nameservers))) (obtain-lock lock) @@ -1014,7 +1017,7 @@ (enqueue! queue result) ;(display "received reply from ")(display nameserver)(display ": ")(display result)(newline) (release-lock lock))))) - (map (lambda (adr32) (address32->ip-string adr32)) (dns-find-nameserver-list))))) + nameserver-list))) (obtain-lock lock) (let loop ((count (length nameserver-list))) @@ -1070,8 +1073,8 @@ (lambda (name . args) (if (null? args) (simple-lookup-function name) - (if (eq? (car args) dns-concurrent-lookup) - (concurrent-lookup simple-lookup-function name) + (if (list? (car args)) + (concurrent-lookup simple-lookup-function name (car args)) (simple-lookup-function name (car args)))))) ;; looks up a hostname, returns an ip. diff --git a/scheme/packages.scm b/scheme/packages.scm index 62d7cbe..c9bddaf 100644 --- a/scheme/packages.scm +++ b/scheme/packages.scm @@ -189,7 +189,6 @@ dns-lookup-ip ; simple lookup function dns-lookup-nameserver ; simple lookup function dns-lookup-mail-exchanger ; simple lookpu function - dns-concurrent-lookup ; the concurrent lookup variable show-dns-message ; prints a human readable dns-msg force-ip ; reruns a lookup until a ip is resolved force-ip-list ; reruns a lookup until a list of ips is resolved