changes in my-reported-fqdn:

* respect change in arguments between different calls before handing out
  cached value
* make its use safe in thread context
This commit is contained in:
interp 2002-08-24 17:26:56 +00:00
parent b20f9a49b7
commit 0119532744
2 changed files with 25 additions and 13 deletions

View File

@ -409,21 +409,32 @@ the requested method (~A).~%"
;;; Return my Internet host name (my fully-qualified domain name). ;;; Return my Internet host name (my fully-qualified domain name).
;;; This works only if an actual resolver is behind host-info. ;;; This works only if an actual resolver is behind host-info.
;;; ;;;
;;; On systems that do DNS via NIS/Yellow Pages, you only get an ;;; In case of aliased names, you just might get the wrong one.
;;; unqualified hostname. Also, in case of aliased names, you just ;;; Furthermore, you may get screwed in the presence of a server
;;; might get the wrong one. Furthermore, you may get screwed in the ;;; accelerator such as Squid.
;;; presence of a server accelerator such as Squid.
(define *fqdn-cache* #f) (define my-reported-fqdn
(let ((fqdn-lock (make-lock))
(define (my-reported-fqdn addr options) (fqdn-cache #f)
(or *fqdn-cache* (used-addr #f)
(begin (used-options #f))
(set! *fqdn-cache* (or (httpd-options-fqdn options) (lambda (addr options)
(dns-lookup-ip (socket-address->string addr)) (obtain-lock fqdn-lock)
(host-info:name (host-info addr)))) (let ((result
*fqdn-cache*))) (if fqdn-cache
(or (and (equal? used-addr addr)
(equal? used-options options)
fqdn-cache)
(begin
(set! fqdn-cache (or (httpd-options-fqdn options)
(dns-lookup-ip (socket-address->string addr))
(host-info:name (host-info addr))))
(set! used-addr addr)
(set! used-options options)
fqdn-cache)))))
(release-lock fqdn-lock)
result))))
(define (my-reported-port addr options) (define (my-reported-port addr options)
(or (httpd-options-reported-port options) (or (httpd-options-reported-port options)

View File

@ -650,6 +650,7 @@
string-lib ; STRING-INDEX string-lib ; STRING-INDEX
dns ; dns-lookup-ip dns ; dns-lookup-ip
sunet-utilities ; socket-address->string sunet-utilities ; socket-address->string
locks ; make-lock et al.
handle-fatal-error handle-fatal-error
httpd-read-options httpd-read-options