From 8a2351a1903104f0c2abcff03042152e262369d9 Mon Sep 17 00:00:00 2001 From: mainzelm Date: Tue, 1 Aug 2006 15:19:19 +0000 Subject: [PATCH] Fix handling of session timeouts by using the session-id as the only key. --- scheme/httpd/surflets/surflet-handler.scm | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/scheme/httpd/surflets/surflet-handler.scm b/scheme/httpd/surflets/surflet-handler.scm index 8e8431c..65508f5 100644 --- a/scheme/httpd/surflets/surflet-handler.scm +++ b/scheme/httpd/surflets/surflet-handler.scm @@ -120,28 +120,26 @@ (define *timeout-queue*) (define (timeout-queue-register-session! session-id timeout) - (search-tree-set! *timeout-queue* (cons session-id timeout) 'ignore)) + (search-tree-set! *timeout-queue* session-id timeout)) (define (timeout-queue-remove-session! session-id) - (search-tree-set! *timeout-queue* (cons session-id 0) #f)) + (search-tree-set! *timeout-queue* session-id #f)) (define (timeout-queue-adjust-session-timeout! session-id new-timeout) - (search-tree-set! *timeout-queue* (cons session-id new-timeout) 'ignore)) + (search-tree-set! *timeout-queue* session-id new-timeout)) (define (surveillance-thread) - (set! *timeout-queue* (make-search-tree (lambda (p q) (eq? (car p) (car q))) - (lambda (p q) - (< (cdr p) (cdr q))))) + (set! *timeout-queue* (make-search-tree = <)) (let lp () (with-lock *session-table-lock* (let ((now (time))) (let lp2 () - (receive (session-id.time ignore) (search-tree-min *timeout-queue*) - (if session-id.time - (if (<= (cdr session-id.time) now) - (let ((session-id (car session-id.time))) - (table-set! *session-table* session-id #f) + (receive (session-id time) (search-tree-min *timeout-queue*) + (if session-id + (if (<= time now) + (begin + (timeout-queue-remove-session! session-id) (pop-search-tree-min! *timeout-queue*) (lp2)))))))) (sleep 1000)