diff --git a/collects/mzlib/thread.ss b/collects/mzlib/thread.ss index d3d45ea..0135fc6 100644 --- a/collects/mzlib/thread.ss +++ b/collects/mzlib/thread.ss @@ -74,50 +74,48 @@ (dynamic-wind void (lambda () - ;; Introduce parameter dynamic binding that we can mutate: - (parameterize ([current-custodian (current-custodian)]) - ;; All connections should use the same parameterization, - ;; to facilitate transferring continuations from one - ;; connection to another: - (let ([paramz (current-parameterization)]) - ;; Loop to handle connections: - (let loop () - (with-handlers ([exn:fail:network? handle-exn]) - ;; Make a custodian for the next session: - (let ([c (make-custodian)]) - (parameterize ([current-custodian c]) - ;; disable breaks during session set-up... - (parameterize-break #f - ;; ... but enable breaks while blocked on an accept: - (let-values ([(r w) ((if can-break? - tcp-accept/enable-break - tcp-accept) - l)]) - ;; Handler thread: - (let ([t (thread (lambda () - ;; First, install the parameterization - ;; used for all connections: - (call-with-parameterization - paramz - (lambda () - ;; Install this connection's custodian - ;; for this thread in the shared - ;; parameterization: - (current-custodian c) - ;; Enable breaking: - (when can-break? - (break-enabled #t)) - ;; Call the handler - (handler r w)))))]) - ;; Clean-up and timeout thread: - (thread (lambda () - (sync/timeout connection-timeout t) - (when (thread-running? t) - ;; Only happens if connection-timeout is not #f - (break-thread t)) - (sync/timeout connection-timeout t) - (custodian-shutdown-all c))))))))) - (loop))))) + ;; All connections should use the same parameterization, + ;; to facilitate transferring continuations from one + ;; connection to another: + (let ([paramz (current-parameterization)]) + ;; Loop to handle connections: + (let loop () + (with-handlers ([exn:fail:network? handle-exn]) + ;; Make a custodian for the next session: + (let ([c (make-custodian)]) + (parameterize ([current-custodian c]) + ;; disable breaks during session set-up... + (parameterize-break #f + ;; ... but enable breaks while blocked on an accept: + (let-values ([(r w) ((if can-break? + tcp-accept/enable-break + tcp-accept) + l)]) + ;; Handler thread: + (let ([t (thread (lambda () + ;; First, install the parameterization + ;; used for all connections: + (call-with-parameterization + paramz + (lambda () + ;; Install this connection's custodian + ;; for this thread in the shared + ;; parameterization: + (current-custodian c) + ;; Enable breaking: + (when can-break? + (break-enabled #t)) + ;; Call the handler + (handler r w)))))]) + ;; Clean-up and timeout thread: + (thread (lambda () + (sync/timeout connection-timeout t) + (when (thread-running? t) + ;; Only happens if connection-timeout is not #f + (break-thread t)) + (sync/timeout connection-timeout t) + (custodian-shutdown-all c))))))))) + (loop)))) (lambda () (tcp-close l)))))) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;