From e98caf31c17c6c063b960a3f296c0385b0c23fb0 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Mon, 9 Oct 2006 19:41:36 +0000 Subject: [PATCH] eli svn: r4534 --- .../web-server/dispatchers/dispatch-passwords.ss | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/collects/web-server/dispatchers/dispatch-passwords.ss b/collects/web-server/dispatchers/dispatch-passwords.ss index 2442d00e78..c042f35177 100644 --- a/collects/web-server/dispatchers/dispatch-passwords.ss +++ b/collects/web-server/dispatchers/dispatch-passwords.ss @@ -20,13 +20,19 @@ (gen-authentication-responder "forbidden.html")] [passwords-refresh-responder (gen-passwords-refreshed "passwords-refresh.html")]) + (define last-read-time (box #f)) (define password-cache (box #f)) - (define (reset-password-cache!) - ; more here - a malformed password file will kill the connection - (set-box! password-cache (read-passwords password-file))) + (define (update-password-cache!) + (define cur-mtime (file-or-directory-modify-seconds password-file)) + (when (or (not (unbox last-read-time)) + (cur-mtime . > . (unbox last-read-time)) + (not (unbox password-cache))) + (set-box! last-read-time cur-mtime) + ; more here - a malformed password file will kill the connection + (set-box! password-cache (read-passwords password-file)))) (define (read-password-cache) + (update-password-cache!) (unbox password-cache)) - (reset-password-cache!) (lambda (conn req) (define-values (uri method path) (decompose-request req)) (cond @@ -38,7 +44,7 @@ realm))] [(string=? "/conf/refresh-passwords" path) ;; more here - send a nice error page - (reset-password-cache!) + (update-password-cache!) (output-response/method conn (passwords-refresh-responder)