New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plack::Handler::Apache2: implement support for cleanup handlers #334

Merged
merged 1 commit into from Sep 30, 2012

Conversation

Projects
None yet
3 participants
@avar
Contributor

avar commented Sep 28, 2012

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.

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.
@miyagawa

This comment has been minimized.

Show comment
Hide comment
@miyagawa

miyagawa Sep 30, 2012

Member

Looks great.

Member

miyagawa commented Sep 30, 2012

Looks great.

miyagawa added a commit that referenced this pull request Sep 30, 2012

Merge pull request #334 from avar/add-support-for-psgix_cleanup-to-ap…
…ache2-handler

Plack::Handler::Apache2: implement support for cleanup handlers

@miyagawa miyagawa merged commit c8d0ffc into plack:master Sep 30, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment