You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Steve Johnson <st...@webninja.com> on 2006/11/02 23:44:18 UTC

Problem with PerlCleanupHandler

Hi, I'm registering a PerlCleanupHandler method in my mod_perl cgi handler.

Using:
$r->set_handlers( PerlCleanupHandler => [ &send_to_client ]);

My goal is to have this service take an xml message, do some processing on
it and reply with a confirm xml message.  Afterward I need to POST a
completely new message to the client unrelated to that connection but
initiated because of it.  I don't want to have to write an external program
(run via cron) to push these messages.  Nor do I have any queue software
installed.  I simply want to register the Cleanup method to do the work
after the response has been sent back to the client and the connection is
closed.  In testing this out, it works pefectly when testing with curl using
a simple GET.  It sends me a response almost immediately, but if i watch the
logs, it processes the cleanuphandler method like it should, after i already
received the response (testing this using a sleep 5; in the top of sub
send_to_client).  However, as soon as I change my request to a POST, it is
blocking.  The request hangs and doesn't send the response to the client
until after the Cleanup method has completed.  Is this proper behaviour?  Is
there a way around this?

Thanks.

-- 
Steve Johnson
steve@webninja.com

Re: Problem with PerlCleanupHandler

Posted by Perrin Harkins <pe...@elem.com>.
On Thu, 2006-11-02 at 16:44 -0600, Steve Johnson wrote:
> In testing this out, it works pefectly when testing with curl using a
> simple GET.  It sends me a response almost immediately, but if i watch
> the logs, it processes the cleanuphandler method like it should, after
> i already received the response (testing this using a sleep 5; in the
> top of sub send_to_client).  However, as soon as I change my request
> to a POST, it is blocking.  The request hangs and doesn't send the
> response to the client until after the Cleanup method has completed.
> Is this proper behaviour?

I don't think so.  I've never observed this.  Is it possible that you're
seeing buffering here?  You can try turning that off with $|=1 and see
what happens.

- Perrin