Remove bug that inhibited POST cache to shrink

This commit is contained in:
interp 2004-09-24 11:28:49 +00:00
parent d904121149
commit f0ca612665
1 changed files with 15 additions and 14 deletions

View File

@ -5,7 +5,7 @@
;; a later GET-BINDINGS call on the same POST request. The requests ;; a later GET-BINDINGS call on the same POST request. The requests
;; are referenced by a weak pointer. Thread-safe as all threads use ;; are referenced by a weak pointer. Thread-safe as all threads use
;; the same lock. ;; the same lock.
(define *POST-bindings-cache* '()) (define *POST-bindings-cache* '(#f))
(define *cache-lock* (make-lock)) (define *cache-lock* (make-lock))
(define (get-bindings surflet-request) (define (get-bindings surflet-request)
@ -55,18 +55,19 @@
(obtain-lock *cache-lock*) (obtain-lock *cache-lock*)
(let ((result (let ((result
(let loop ((cache *POST-bindings-cache*)) (let loop ((cache *POST-bindings-cache*))
(if (null? cache) (let ((tail (cdr cache)))
(if (null? tail) ; cache has at least one element
#f ; no such request cached #f ; no such request cached
(let* ((head (car cache)) (let* ((head (car tail))
(s-req (weak-pointer-ref (car head)))) (s-req (weak-pointer-ref (car head))))
(if s-req (if s-req
(if (eq? s-req surflet-request) (if (eq? s-req surflet-request)
(cdr head) ; request is cached (cdr head) ; request is cached
(loop (cdr cache))) ; request isn't cached (loop (cdr cache))) ; request isn't cached
(begin (begin ;; request object is gone ==> remove
;; request object is gone ==> remove it from list ;; it from list
(set! cache (cdr cache)) (set-cdr! cache (cdr tail))
(loop cache)))))))) (loop cache)))))))))
(release-lock *cache-lock*) (release-lock *cache-lock*)
result)) result))