We definitely have the process pool (thats the pool that calls the destructors on your modules. What are you looking for when you say 'server_rec'? Do you mean the cmd_parms->server? We do have that, and it could be included in the process to load the modules. Let me know specifically what you are looking for and i'll ponder the change - Thanks for the great input!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, cmd_parms->server. I would like the hostname and port when I instantiate a handler derived from ApacheHandler. This is nice, but not strictly necessary.
The pool is necessary so I can use a placement new operator to allocate the derived object from the server pool. I think this is proper way to do this.
I have added the following code to my derived class:
What I usually do is just make sure my Handler destructor cleans up all the objects - the server pool has a cleanup that should delete all Handlers before the pool goes away - which is a little cleaner than overloading 'new' - would that work for you? Its not a bad idea to pass it in to the constructor either way, but usually I don't allocate out of the pool from within my handlers, I just manage my own memory.
Would that work for you?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In developing my handler, I find that having the pool and server_rec in the instanciator would be helpful. Any reason to no pass them?
Hi -
We definitely have the process pool (thats the pool that calls the destructors on your modules. What are you looking for when you say 'server_rec'? Do you mean the cmd_parms->server? We do have that, and it could be included in the process to load the modules. Let me know specifically what you are looking for and i'll ponder the change - Thanks for the great input!
Yes, cmd_parms->server. I would like the hostname and port when I instantiate a handler derived from ApacheHandler. This is nice, but not strictly necessary.
The pool is necessary so I can use a placement new operator to allocate the derived object from the server pool. I think this is proper way to do this.
I have added the following code to my derived class:
<pre>
void* operator new(size_t size, apr_pool_t* pool)
{
return apr_palloc(pool, size);
}
</pre>
and the instantiate_handler looks like this:
<pre>
ApacheHandler *instantiate_handler(apr_pool_t* pool,
cpp_server_rec* server_rec)
{
return new(pool) PiaHandler();
}
</pre>
Hi -
What I usually do is just make sure my Handler destructor cleans up all the objects - the server pool has a cleanup that should delete all Handlers before the pool goes away - which is a little cleaner than overloading 'new' - would that work for you? Its not a bad idea to pass it in to the constructor either way, but usually I don't allocate out of the pool from within my handlers, I just manage my own memory.
Would that work for you?
Okay, I dug thru code some more and understand better how it works. I withdraw my request for pool to be passed to instantiator.