From 24214819dc52ac9a2c3e0682bccb8a4ea638f032 Mon Sep 17 00:00:00 2001 From: sperber Date: Thu, 21 Feb 2002 16:12:22 +0000 Subject: [PATCH] Prevent log interaction with a lock. Don't do a DNS lookup for log entries. --- httpd-core.scm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/httpd-core.scm b/httpd-core.scm index ee459e5..f6f59c8 100644 --- a/httpd-core.scm +++ b/httpd-core.scm @@ -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,11 +189,15 @@ (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.")