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 Sorin Manolache <so...@gmail.com> on 2008/07/09 23:19:03 UTC
module initialisation
Hello,
I am writing a DSO apache module that needs some
initialisation---shared memory segment creation and a pipe---before
performing its work.
I have hooked post_config and I have put the initialisation there.
static int *seg = NULL;
static int p[2];
post_config_hook() {
if (seg == NULL) {
seg = blabla;
}
if (p[0] == 0) {
pipe(p);
}
}
When I do an "/etc/init.d/apache2 reload", the post_config hook is
executed again (as expected), but seg is NULL again and I create yet
another shared memory segment.
Can someone tell me please why are all my variables reinitialised
after a reload?
I really checked /proc/PID_of_apache2/fd and after each reload I have
two more file descriptors opened (corresponding to the two endpoints
of the pipe p).
What's the solution to my problem, namely module initialisation that
is persistent across apache reloads?
Thank you very much,
Sorin
Re: module initialisation
Posted by Nick Kew <ni...@webthing.com>.
On Wed, 9 Jul 2008 23:19:03 +0200
"Sorin Manolache" <so...@gmail.com> wrote:
> When I do an "/etc/init.d/apache2 reload", the post_config hook is
> executed again (as expected), but seg is NULL again and I create yet
> another shared memory segment.
Reload isn't an apache term. It's your package's alias for something,
probably a graceful restart.
If your module creates a resource (like a shm segment), it should
register a pool cleanup on the resource at the same time.
http://www.apachetutor.org/dev/pools
> What's the solution to my problem, namely module initialisation that
> is persistent across apache reloads?
Your module will need to reference something external, as it would to
implement persistence over a server restart. See for example SQL-based
configuration modules.
--
Nick Kew
Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/