Sort out stuff around `timeout-control'.

1. The contract in the docs was wrong.

2. The docs used `#f' where the code was expecting 'disable, so made it
   accept both.

3. Don't recommend disabling the timer -- I had a case where the
   connection was left for more than a day as a result.  (Probably
   because there was a message after the receipt email.)
This commit is contained in:
Eli Barzilay 2012-01-23 17:05:39 -05:00
parent 01dce00271
commit 3dd9001fdd
3 changed files with 9 additions and 9 deletions

View File

@ -600,7 +600,7 @@
(set! timeout (+ (current-inexact-milliseconds) (* 1000 msg))) (set! timeout (+ (current-inexact-milliseconds) (* 1000 msg)))
(case msg (case msg
[(reset) (timeout-control (get-conf 'session-timeout))] [(reset) (timeout-control (get-conf 'session-timeout))]
[(disable) (set! timeout #f)] [(disable #f) (set! timeout #f)]
[else (error 'timeout-control "bad argument: ~s" msg)]))) [else (error 'timeout-control "bad argument: ~s" msg)])))
(current-timeout-control timeout-control) (current-timeout-control timeout-control)
(timeout-control 'reset) (timeout-control 'reset)

View File

@ -235,10 +235,10 @@ code.}
the description of the @racket[pre-checker] and the description of the @racket[pre-checker] and
@racket[post-checker] values for what can be done with these, and @racket[post-checker] values for what can be done with these, and
note that the check for valid users is always first. An example for note that the check for valid users is always first. An example for
a sophisticated @racket[post:] block is below---it will first a sophisticated @racket[post:] block is below---it will first set a
disable timeouts for this session, then it will send a email with a very long timeout for this session, then it will send an email with
submission receipt, with CC to the TA (assuming a single TA), and a submission receipt, with a CC to the TA (assuming a single TA),
pop-up a message telling the student about it: and pop-up a message telling the student about it:
@racketblock[ @racketblock[
(require net/sendmail) (require net/sendmail)
@ -247,7 +247,7 @@ code.}
(format "hw.rkt: ~a ~a" (format "hw.rkt: ~a ~a"
(file-size "hw.rkt") (file-size "hw.rkt")
(file-or-directory-modify-seconds "hw.rkt"))) (file-or-directory-modify-seconds "hw.rkt")))
(timeout-control 'disable) (timeout-control 300)
(log-line "Sending a receipt: ~a" info) (log-line "Sending a receipt: ~a" info)
(send-mail-message (send-mail-message
"course-staff@university.edu" "course-staff@university.edu"

View File

@ -190,7 +190,7 @@ Every exception or result mismatch during the call to
and flush it. (The log port will prefix all lines with a time stamp and flush it. (The log port will prefix all lines with a time stamp
and a connection identifier.)} and a connection identifier.)}
@defproc[(timeout-control [msg string?]) void?]{ @defproc[(timeout-control [msg any?]) void?]{
Controls the timeout for this session. The timeout is initialized Controls the timeout for this session. The timeout is initialized
by the value of the @racket[session-timeout] configuration entry, by the value of the @racket[session-timeout] configuration entry,
@ -198,8 +198,8 @@ Every exception or result mismatch during the call to
@racket[msg] is @racket['reset] the timeout is reset to @racket[msg] is @racket['reset] the timeout is reset to
@racket[session-timeout] seconds; if @racket[msg] is a number the @racket[session-timeout] seconds; if @racket[msg] is a number the
timeout will be set to that many seconds in the future. The timeout timeout will be set to that many seconds in the future. The timeout
can be completely disabled by @racket[(timeout-control #f)]. (Note can be completely disabled using @racket['disable] or @racket[#f].
that before the checker is used (after the pre-checker, if (Note that before the checker is used (after the pre-checker, if
specified), the timer will be reset to the @racket['session-timeout] specified), the timer will be reset to the @racket['session-timeout]
value.)} value.)}