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,22 +55,23 @@
(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)))
#f ; no such request cached (if (null? tail) ; cache has at least one element
(let* ((head (car cache)) #f ; no such request cached
(s-req (weak-pointer-ref (car head)))) (let* ((head (car tail))
(if s-req (s-req (weak-pointer-ref (car head))))
(if (eq? s-req surflet-request) (if s-req
(cdr head) ; request is cached (if (eq? s-req surflet-request)
(loop (cdr cache))) ; request isn't cached (cdr head) ; request is cached
(begin (loop (cdr cache))) ; request isn't cached
;; request object is gone ==> remove it from list (begin ;; request object is gone ==> remove
(set! cache (cdr cache)) ;; it from list
(loop cache)))))))) (set-cdr! cache (cdr tail))
(loop cache)))))))))
(release-lock *cache-lock*) (release-lock *cache-lock*)
result)) result))
;; Will be needed when we handle POST requests. ;; Will be needed when we handle POST requests.
(define (get-content-length headers) (define (get-content-length headers)
(cond ((get-header headers 'content-length) => (cond ((get-header headers 'content-length) =>