plack/Plack — pull request #334 by avar (2012-09-28 10:30:45+00:00)
Title: Plack::Handler::Apache2: implement support for cleanup handlers

Change Plack::Handler::Apache2 to Implement support for the PSGI
environment cleanup handlers proposal specified at
https://github.com/plack/psgi-specs/wiki/Proposal:-PSGI-environment-cleanup-handlers. Being
able to emulate Apache-like behavior was the original reason for the
proposal, so it's fitting that we should have support for this in our
Apache compatibility layer.

The same patch should work pretty much as-is for Apache1 as well, but
I don't have access to an Apache1 server anymore so I've just
implemented it for Apache2.

Note that we check psgix.harakiri.commit after the cleanup handlers
have run in case one of the cleanup handlers sets that flag, if we
don't have any cleanup handlers we ask the server to child_terminate()
without setting up a PerlCleanupHandler.

This is perhaps a needles premature optimization (we could just get
rid of that if() entirely and always do "push_handlers"), but it
seemed to be superfluous to always set up a PerlCleanupHandler even
when we don't need any asynchronous cleanup, but only child
termination.

This patch is best viewed with "git show -w", I re-indented the
key/values in the $env assignment to fit the current coding style of
that file, but I didn't change any of the existing keys there. I only
added psgix.cleanup and psgix.cleanup.handlers.