You can solve your problem in this way:
static int initialize_your_module(apr_pool_t *p, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s) {
void *data;
const char *userdata_key = "unique_key_init";
apr_pool_userdata_get(&data, userdata_key, s->process->pool);
if (!data) {
apr_pool_userdata_set((const void *)1, userdata_key,
apr_pool_cleanup_null, s->process->pool);
return OK;
}
if (init_strutture(s, p) != APR_SUCCESS) {
return !OK;
}
return OK;
}
.....
static void register_hooks(apr_pool_t *p)
{
ap_hook_post_config(initialize_your_module, NULL, NULL,
APR_HOOK_MIDDLE);
.....
}
You have to do all your unique operations in init_strutture function.
Marco
Ray Morris ha scritto:
That was the idea I had, but it seems it is a brand new run
of all my code, thus the variable values are lost and re-initialized.
Page 23 of Nick's book talks about the configuration
being read twice - once while the server is running as
root, to make sure that the configuration is valid,
then again as Apache goes into operational mode as
user "nobody" or "apache".
Also look into the preconfiguration and postconfiguration
hooks, mentioned on page 66, as well as the monitor hook.
I'm not knowledgeable enough to give you a solid answer, but
this information may provide the "hint" you need to be able
to get it figured out.
--
Ray B. Morris
[EMAIL PROTECTED]
Strongbox - The next generation in site security:
http://www.bettercgi.com/strongbox/
Throttlebox - Intelligent Bandwidth Control
http://www.bettercgi.com/throttlebox/
Strongbox / Throttlebox affiliate program:
http://www.bettercgi.com/affiliates/user/register.php
On 04/08/2008 02:04:53 PM, Andy Grant wrote:
That was the idea I had, but it seems it is a brand new run of all my
code, thus the variable values are lost and re-initialized. I've been
working on writing to a file on disk, and reading that in, but that
is
a
lot of over head I'd like to avoid.
Thanks though.
Ray Morris wrote:
I am writing a module that runs certain functions depending on the
configuration directives in the conf files. The functions are run
twice when the server is started and again when the server shuts
down.
I think I read something about this in Nick's
book, but I don't recall exactly. Anyway in case
someone more knowledgeable than I doesn't reply, remember
you can of course just set a variable the first time your
functions are run and then on future invocations you'll
return immediately if the variable is already set.
--
Ray B. Morris
[EMAIL PROTECTED]
On 04/08/2008 01:44:35 PM, Andy Grant wrote:
I am writing a module that runs certain functions depending on the
configuration directives in the conf files. The functions are run
twice
when the server is started and again when the server shuts down.
Is
there a way to make the functions run only once? Maybe some
variable
that can be checked stating that the server is reading the conf
files,
actually starting the server, or shutting down?
Thanks