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)