Prevent log interaction with a lock.

Don't do a DNS lookup for log entries.
This commit is contained in:
sperber 2002-02-21 16:12:22 +00:00
parent 5e1193c60a
commit 24214819dc
1 changed files with 12 additions and 6 deletions

View File

@ -52,6 +52,7 @@
(define *http-log?* #t)
(define *http-log-port* #f)
(define *http-log-lock* (make-lock))
(define (init-http-log!)
(set! *http-log-port* (current-error-port)))
@ -59,9 +60,10 @@
(define (http-log fmt . args)
(if *http-log?*
(begin
(obtain-lock *http-log-lock*)
(apply format *http-log-port* fmt args)
(force-output *http-log-port*)
)))
(release-lock *http-log-lock*))))
;;; (httpd path-handler [port server-root-dir])
@ -187,10 +189,14 @@
(let ((line (read-crlf-line)))
;; Blat out some logging info.
(if *http-log?*
(let* ((addr (socket-remote-address sock))
(host (host-name-or-ip addr)))
(http-log "~a: ~a~%" host line)))
(if *http-log?*
(call-with-values
(lambda ()
(socket-address->internet-address (socket-remote-address sock)))
(lambda (host-address service-port)
(http-log "~a: ~a~%"
(format-internet-host-address host-address)
line))))
(if (eof-object? line)
(fatal-syntax-error "EOF while parsing request.")