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,22 +55,23 @@
(obtain-lock *cache-lock*)
(let ((result
(let loop ((cache *POST-bindings-cache*))
(if (null? cache)
#f ; no such request cached
(let* ((head (car cache))
(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))))))))
(let ((tail (cdr cache)))
(if (null? tail) ; cache has at least one element
#f ; no such request cached
(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-cdr! cache (cdr tail))
(loop cache)))))))))
(release-lock *cache-lock*)
result))
;; Will be needed when we handle POST requests.
(define (get-content-length headers)
(cond ((get-header headers 'content-length) =>