miyagawa/Starman — pull request #53 by avar (2012-09-12 10:11:01+00:00)
Title: Implement support for the PSGI environment cleanup handlers proposal

This should address the issues noted in https://github.com/miyagawa/Starman/pull/52

Implement the proposal at
https://github.com/plack/psgi-specs/wiki/Proposal:-PSGI-environment-cleanup-handlers. This
seems to work for me, at least the subroutines get run, and you can
e.g. "sleep 10" in the cleanup handler without holding up the request.

One potential caveat here is that by passing the $env hash to the
post_client_connection_hook routine we might be causing something
evil, but I haven't spotted any problems with it so far.

Note that we have to re-check the harakiri flag in
post_client_connection_hook because the cleanup handlers might set it.