Adding lock to servlet cache table

svn: r97
This commit is contained in:
Jay McCarthy 2005-06-14 12:44:04 +00:00
parent 28a243cc66
commit e502ec19b9
3 changed files with 11 additions and 4 deletions

View File

@ -99,6 +99,7 @@
(define access (make-hash-table))
(define instances (make-hash-table))
(define scripts (box (make-hash-table 'equal)))
(define scripts-lock (make-semaphore 1))
(define make-servlet-namespace the-make-servlet-namespace)))
; begin stolen from commander.ss, which was stolen from private/drscheme/eval.ss

View File

@ -17,6 +17,7 @@
virtual-hosts
access
scripts ;; : equal-hash-table
scripts-lock
initial-connection-timeout))
; more here - rename

View File

@ -143,7 +143,9 @@
[(string=? "/conf/refresh-servlets" path)
;; more here - this is broken - only out of date or specifically mentioned
;; scripts should be flushed. This destroys persistent state!
(set-box! config:scripts (make-hash-table 'equal))
(call-with-semaphore config:scripts-lock
(lambda ()
(set-box! config:scripts (make-hash-table 'equal))))
(output-response/method
conn
((responders-servlets-refreshed (host-responders host-info)))
@ -590,9 +592,11 @@
;; timestamps are no longer checked for performance. The cache must be explicitly
;; refreshed (see dispatch).
(define (cached-load name)
(hash-table-get (unbox config:scripts)
name
(lambda () (reload-servlet-script name))))
(call-with-semaphore config:scripts-lock
(lambda ()
(hash-table-get (unbox config:scripts)
name
(lambda () (reload-servlet-script name))))))
;; exn:i/o:filesystem:servlet-not-found =
;; (make-exn:fail:filesystem:exists:servlet str continuation-marks str sym)
@ -605,6 +609,7 @@
(cond
[(load-servlet/path servlet-filename)
=> (lambda (svlt)
; This is only called from cached-load, so config:scripts is locked
(hash-table-put! (unbox config:scripts) servlet-filename svlt)
svlt)]
[else