From 9146cb57808f54a8fde8ebd0b18480dd574bc251 Mon Sep 17 00:00:00 2001 From: mainzelm Date: Sun, 29 Dec 2002 19:10:10 +0000 Subject: [PATCH] Use with-lock to obtain/release-locks. --- scheme/httpd/logging.scm | 54 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/scheme/httpd/logging.scm b/scheme/httpd/logging.scm index 5a0928b..003edd4 100644 --- a/scheme/httpd/logging.scm +++ b/scheme/httpd/logging.scm @@ -63,10 +63,10 @@ (set-logging-http-syslog? #t) (set-logging-http-syslog-proc (lambda (level fmt . args) - (obtain-lock http-syslog-lock) - (syslog level - (apply format #f fmt args)) - (release-lock http-syslog-lock)))) + (with-lock http-syslog-lock + (lambda () + (syslog level + (apply format #f fmt args))))))) (begin (set-logging-http-syslog? #f) (set-logging-http-syslog-proc do-nothing-proc)))) @@ -98,24 +98,23 @@ (define (make-http-log-proc http-log-lock) (lambda (req status-code) (if req - (begin - (obtain-lock http-log-lock) - (display (make-CLF - (receive (host-address _) - (socket-address->internet-address - (socket-remote-address (request-socket req))) - (format-internet-host-address host-address)) - (request-method req) ; request method - (uri-path-list->path - (http-url-path (request-url req))) ; requested file - (version->string (request-version req)) ; protocol version - status-code - 23 ; filesize (unknown) - (get-header (request-headers req) 'referer) - (get-header (request-headers req) 'user-agent)) - (logging-http-log-port)) - (force-output (logging-http-log-port)) - (release-lock http-log-lock))))) + (with-lock http-log-lock + (lambda () + (display (make-CLF + (receive (host-address _) + (socket-address->internet-address + (socket-remote-address (request-socket req))) + (format-internet-host-address host-address)) + (request-method req) ; request method + (uri-path-list->path + (http-url-path (request-url req))) ; requested file + (version->string (request-version req)) ; protocol version + status-code + 23 ; filesize (unknown) + (get-header (request-headers req) 'referer) + (get-header (request-headers req) 'user-agent)) + (logging-http-log-port)) + (force-output (logging-http-log-port))))))) ;; does the logfile rotation on signal USR1 @@ -125,10 +124,10 @@ (on-interrupt interrupt/usr1 (lambda () - (obtain-lock http-log-lock) - (close-output-port (logging-http-log-port)) - (set-logging-http-log-port (open-logfile logfile)) - (release-lock http-log-lock))))) + (with-lock http-log-lock + (lambda () + (close-output-port (logging-http-log-port)) + (set-logging-http-log-port (open-logfile logfile)))))))) (define (open-logfile logfile) (with-errno-handler* @@ -166,6 +165,9 @@ (if (logging-dns-lookup?) (or (with-fatal-error-handler* (lambda (condition decline) + (http-syslog (syslog-level debug) + "An error occured while resolving IP ~A: ~A" + remote-ip condition) remote-ip) (lambda () (dns-lookup-ip remote-ip)))