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
;; are referenced by a weak pointer. Thread-safe as all threads use
;; the same lock.
(define *POST-bindings-cache* '())
(define *POST-bindings-cache* '(#f))
(define *cache-lock* (make-lock))
(define (get-bindings surflet-request)
@ -55,18 +55,19 @@
(obtain-lock *cache-lock*)
(let ((result
(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
(let* ((head (car cache))
(let* ((head (car tail))
(s-req (weak-pointer-ref (car head))))
(if s-req
(if (eq? s-req surflet-request)
(cdr head) ; request is cached
(loop (cdr cache))) ; request isn't cached
(begin
;; request object is gone ==> remove it from list
(set! cache (cdr cache))
(loop cache))))))))
(begin ;; request object is gone ==> remove
;; it from list
(set-cdr! cache (cdr tail))
(loop cache)))))))))
(release-lock *cache-lock*)
result))