diff --git a/scheme/httpd/surflets/surflet-handler.scm b/scheme/httpd/surflets/surflet-handler.scm index d90cc6b..17ad340 100644 --- a/scheme/httpd/surflets/surflet-handler.scm +++ b/scheme/httpd/surflets/surflet-handler.scm @@ -41,14 +41,15 @@ (cache-servlets? #t) (instance-lifetime 600)) ; in seconds -(define *options* (make-thread-cell #f)) -;(define *options-lock* (make-lock)) ; currently unused +(define *options* (make-preserved-thread-fluid #f)) +;; preserved thread fluid because between different calls to +;; servlet-handler the options shall remain the same. (define (make-fluid-selector selector) - (lambda () (selector (thread-cell-ref *options*)))) + (lambda () (selector (thread-fluid *options*)))) (define (make-fluid-setter setter) (lambda (value) - (setter (thread-cell-ref *options*) value))) + (setter (thread-fluid *options*) value))) (define options-servlet-path (make-fluid-selector options:servlet-path)) (define options-servlet-prefix (make-fluid-selector options:servlet-prefix)) (define options-cache-servlets? (make-fluid-selector options:cache-servlets?)) @@ -69,8 +70,8 @@ ;; servlet-prefix gives virtual prefixed path to servlets (define (servlet-handler servlet-path servlet-prefix) + (set-thread-fluid! *options* (make-options servlet-path servlet-prefix)) (lambda (path req) - (thread-cell-set! *options* (make-options servlet-path servlet-prefix)) (if (pair? path) ; need at least one element (let ((request-method (request:method req)) (path-string (uri-path-list->path path)))