diff --git a/scheme/httpd/surflets/surflet-handler.scm b/scheme/httpd/surflets/surflet-handler.scm index ac66f32..8f16338 100644 --- a/scheme/httpd/surflets/surflet-handler.scm +++ b/scheme/httpd/surflets/surflet-handler.scm @@ -316,9 +316,11 @@ ;; surveillance of killing new session that has the same number by ;; accident) (let ((session (table-ref *session-table* session-id))) - (memo-killed! (session-memo session))) - ;; why can't table entries be deleted correctly? - (table-set! *session-table* session-id #f) + (if session + (begin + (memo-killed! (session-memo session)) + (table-set! *session-table* session-id #f)))) + ;; else: somebody was faster than we (release-lock *session-table-lock*)) ;;; SESSION-ADJUST-TIMEOUT! @@ -330,17 +332,21 @@ (define (really-session-adjust-timeout! session-id time-to-live) (obtain-lock *session-table-lock*) - (let* ((session (table-ref *session-table* session-id)) - (memo (session-memo session)) - (new-memo (make-default-memo))) - ;; Do it this way: new values and then new message - (set-memo:value memo - (+ (time) time-to-live)) - (set-memo:new-memo memo new-memo) - ;; I don't think we need locking here. Do you agree? - (set-session-memo! session new-memo) - (set-memo:message memo 'adjust-timeout)) - (release-lock *session-table-lock*)) + (let ((session (table-ref *session-table* session-id)) + (new-memo (make-default-memo))) + (if session + (let ((memo (session-memo session))) + ;; Do it this way: new values and then new message + (set-memo:value memo + (+ (time) time-to-live)) + (set-memo:new-memo memo new-memo) + ;; I don't think we need locking here. Do you agree? + (set-session-memo! session new-memo) + (set-memo:message memo 'adjust-timeout) + (release-lock *session-table-lock*)) + (begin + (release-lock *session-table-lock*) + (error "There is no session with this ID" session-id))))) ;;; ADJUST-TIMEOUT! ;; Resets time-to-die of current session. The argument must be @@ -522,13 +528,13 @@ ;;; RESET-SURFLET-CACHE! ;; Clears *SURFLET-TABLE* (locking). (define (reset-surflet-cache!) - (with-fatal-handler - (lambda (condition decline) - (release-lock *surflet-table-lock*) - (decline)) +; (with-fatal-handler +; (lambda (condition decline) +; (release-lock *surflet-table-lock*) +; (decline)) (obtain-lock *surflet-table-lock*) (set! *surflet-table* (make-string-table)) - (release-lock *surflet-table-lock*))) + (release-lock *surflet-table-lock*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; INSTANCE