[racket-dev] [plt] Push #24082: master branch updated

From: Jay McCarthy (jay at racket-lang.org)
Date: Thu Mar 22 17:27:46 EDT 2012

Someone else noticed this warning.

http://bugs.racket-lang.org/query/?cmd=view&pr=12443

As the comment below mentions, I don't actually know how to get rid of
the warning, but it doesn't cause problems anymore.

Does anyone have any ideas or thoughts?

Sam TH said he thinks the answer is probably "kill-safety and then
read the PLDI paper 20 times".

Jay

On Tue, Jan 3, 2012 at 3:05 PM,  <jay at racket-lang.org> wrote:
> jay has updated `master' from 160fcacad6 to ef1278d6e1.
>  http://git.racket-lang.org/plt/160fcacad6..ef1278d6e1
>
> =====[ 3 Commits ]======================================================
>
> Directory summary:
>  42.9% collects/mzlib/
>
> ~~~~~~~~~~
>
> 022ce2d Jay McCarthy <jay at racket-lang.org> 2012-01-03 14:11
> :
> | Fixing PR12443
> |
> | There is a big comment in thread.rkt that explains the problem and the
> | "fix". I think something better could and should be done, but I don't
> | know what it is.
> :
>  M collects/mzlib/thread.rkt |  111 +++++++++++++++++++++++++-----------------
>
> =====[ Overall Diff ]===================================================
>
> collects/mzlib/thread.rkt
> ~~~~~~~~~~~~~~~~~~~~~~~~~
> --- OLD/collects/mzlib/thread.rkt
> +++ NEW/collects/mzlib/thread.rkt
> @@ -59,51 +59,72 @@
>     (let ([l (tcp-listen port-number 5 #t)]
>           [can-break? (break-enabled)])
>       (dynamic-wind
> -        void
> -        (lambda ()
> -          ;; 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)))))
> +          void
> +          (lambda ()
> +            ;; 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 ()
> +                ;; Introducing this thread causes PR12443 to no longer fail.
> +
> +                ;; The Web Server will definitely kill the custodian
> +                ;; associated with the resources of the connection. I
> +                ;; think what is going on is that the loop here is
> +                ;; attached to one of these custodians (eventually)
> +                ;; and then the listening loop thread gets killed
> +                ;; too. This patch basically just disconnects the loop
> +                ;; from the new custodian. The error reported in the
> +                ;; PR still shows up, but it has no effect on the
> +                ;; response time/etc, whereas before it would stop
> +                ;; listening and 'ab' would fail.
> +                (thread-wait
> +                 (thread
> +                  (λ ()
> +                     (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)))))
>
>   ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>   ;; Couroutine


Posted on the dev mailing list.