You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Martin Townsend <ma...@power-oasis.com> on 2010/10/11 16:14:02 UTC

Memory Pool

  Hi,

I have created a pool from the child pool for storing warning messages 
that can live across requests, the final request will insert the 
warnings into the response.  How do I ensure that this pool is cleared 
at the end of the final request?

Cheers,
Martin.

-- 
Martin Townsend
Power*Oasis*
Suite 1, Unit 41
Shrivenham Hundred Business Park
Majors Road
Watchfield
Swindon
Wilts SN6 8TZ

Mobile: 07884 444658
Skype: mtownsend1973

Re: Memory Pool

Posted by Ben Noordhuis <in...@bnoordhuis.nl>.
Martin, if you are working in a constrained environment, then you are
probably better off using something like libmicrohttpd[1] or
libevent's evhttp interface[2]. Apache has a rather heavy resource
footprint.

[1] http://www.gnu.org/software/libmicrohttpd/
[2] http://monkey.org/~provos/libevent/doxygen/evhttp_8h.html

Re: Memory Pool

Posted by Martin Townsend <ma...@power-oasis.com>.
  On 11/10/2010 20:48, Nick Kew wrote:
> On Mon, 11 Oct 2010 15:14:02 +0100
> Martin Townsend<ma...@power-oasis.com>  wrote:
>
>>    Hi,
>>
>> I have created a pool from the child pool for storing warning messages
>> that can live across requests, the final request will insert the
>> warnings into the response.  How do I ensure that this pool is cleared
>> at the end of the final request?
> That doesn't really make sense.  What is "the final request"?
>
> If it's requests in a connection, use the connection pool.
> Otherwise, you're looking at a time-based solution such
> as garbage collection.
>

Thanks for the reply and Apologies, I should have put a bit more detail 
in.  I'm working on a module for an embedded platform where we can use 
the web server to configure the firmware.  The interface between the 
module and firmware allows the firmware to send back warning messages 
for side effects of configuration changes.  The time taken for the 
configuration change will likely outlive the connection timeout.  I 
could increase this timeout but I would like to keep it short as you can 
only connect to the web server from a local network and then I can keep 
the number of child processes low.

These warnings are inserted into a response as a table within a DIV HTML 
element by my output filter.  So what usually happens is that the first 
request is a POST with the configure command, an input filter parses 
this and sends the configure to the firmware, the firmware then may send 
back warning messages.  Theses are collected and stored in a list.  The 
next request (which I wrongly referred to as the final request) will 
then have the warning table inserted into the response to which the 
client can then use javascript to display as an overlay.

I've implemented a solution where I use a sub pool from the child pool 
which is now cleared using a flag which I set when the warnings are 
processed by the output filter.  The next (initial) request will then 
pick up the flag and clear the pool.  What I was hoping for, is a hook 
at a point after the data had been sent but the flag works well.

-- 
Martin Townsend
Power*Oasis*
Suite 1, Unit 41
Shrivenham Hundred Business Park
Majors Road
Watchfield
Swindon
Wilts SN6 8TZ

Mobile: 07884 444658
Skype: mtownsend1973

Re: Memory Pool

Posted by Nick Kew <ni...@apache.org>.
On Mon, 11 Oct 2010 15:14:02 +0100
Martin Townsend <ma...@power-oasis.com> wrote:

>   Hi,
> 
> I have created a pool from the child pool for storing warning messages 
> that can live across requests, the final request will insert the 
> warnings into the response.  How do I ensure that this pool is cleared 
> at the end of the final request?

That doesn't really make sense.  What is "the final request"?

If it's requests in a connection, use the connection pool.
Otherwise, you're looking at a time-based solution such
as garbage collection.

-- 
Nick Kew

Re: Memory Pool

Posted by Ben Noordhuis <in...@bnoordhuis.nl>.
On Mon, Oct 11, 2010 at 16:40, Martin Townsend
<ma...@power-oasis.com> wrote:
> use, or should I set a flag and then use a hook like fix-ups that will check
> this flag and then call  apr_pool_clear()?

This. You can use a request note for a flag.

Re: Memory Pool

Posted by Martin Townsend <ma...@power-oasis.com>.
  On 11/10/2010 15:36, Ben Noordhuis wrote:
> On Mon, Oct 11, 2010 at 16:14, Martin Townsend
> <ma...@power-oasis.com>  wrote:
>> I have created a pool from the child pool for storing warning messages that
>> can live across requests, the final request will insert the warnings into
>> the response.  How do I ensure that this pool is cleared at the end of the
>> final request?
> By calling apr_pool_clear() or apr_pool_destroy()?
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 10.0.1120 / Virus Database: 422/3189 - Release Date: 10/10/10
>

Thanks for the response, the problem I have is where do I call 
apr_pool_clear(), if I call it from the output filter then the warnings 
will be freed before they are sent in the response.  Is there a hook 
that I could use, or should I set a flag and then use a hook like 
fix-ups that will check this flag and then call  apr_pool_clear()?

-- 
Martin Townsend
Power*Oasis*
Suite 1, Unit 41
Shrivenham Hundred Business Park
Majors Road
Watchfield
Swindon
Wilts SN6 8TZ

Mobile: 07884 444658
Skype: mtownsend1973

Re: Memory Pool

Posted by Ben Noordhuis <in...@bnoordhuis.nl>.
On Mon, Oct 11, 2010 at 16:14, Martin Townsend
<ma...@power-oasis.com> wrote:
> I have created a pool from the child pool for storing warning messages that
> can live across requests, the final request will insert the warnings into
> the response.  How do I ensure that this pool is cleared at the end of the
> final request?

By calling apr_pool_clear() or apr_pool_destroy()?