httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Kew <>
Subject Re: After-request hooks or asychronous modules
Date Sun, 28 Feb 2010 00:41:54 GMT
On Sun, 28 Feb 2010 00:50:52 +0100
Samuel ROZE <> wrote:

> Hello,
> I'm writing an Apache2 module which takes some time to be executed
> (500ms avg) because it is communicating with another server for each
> request. What is it doing haven't any consequence on the served page
> or file, so it can be run after that the connection with the client
> was closed.
> Now, it is working as a basic module, with libcurl and each request
> take 500ms because it is executed after sending the result page, even
> if it's not needed... Is it possible to execute a module after that
> the request was done? Or is it possible to create a function which
> will be called at this time using a hook?

[this should really be on modules-dev]

All you *should* need to do is send an EOS bucket at the end of your
response before running backend stuff.  Oh, and be sure to have
consumed all input: possibly call ap_discard_request_body yourself
to munch any unexpected input if your module doesn't already
ensure it's fully consumed.  Have you tried that?

If that fails (maybe some filter eats it), you could run the
backend stuff asyncronously - e.g. give it a dedicated thread and
communicate via an APR queue.  That's complicated by resource
management: your module will need pools that outlive a request
but are cleaned up after the backend stuff.

Nick Kew

View raw message