Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change 
notification.

The following page has been changed by MarcMongenet:
http://wiki.apache.org/httpd/ModuleLife

The comment on the change is:
userdata in post_config phase

------------------------------------------------------------------------------
- =Modulie life=
+  * The module is dynamically loaded in the single-process single-thread 
server, that is still running as root if it was started as root.
+  * The configuration is parsed, to check that is is valid.
+  * The module post_init hook is called for the 1st time.
+  * Depending on platform, the module is completely unloaded and reloaded. It 
means that all global variables are lost.
+  * The configuration is parsed again, for real this time.
+  * The module post_init is called for the 2nd time.
+  * Child processes are started, they may be forked, or not (Windows).
+  * If the child processes are not forked, they repeat the startup, with 2 
configurations parsing.
+  * On restart and gracefull restart, the module is unloaded and reloaded/init
  
+ In the post_config hook, we use apr_pool_userdata_get/set to detect if we are 
called for the first time or not. Using a static variable does not work because 
the module may be unloaded/reloaded between the two calls.
- * The module is dynamically loaded in the single-process single-thread 
server, that is still running as root if it was started as root.
- * The configuration is parsed.
- * The module post_init hook is called for the 1st time.
- * Depending on platform, the module is comple
  
+ {{{
+ static int my_module_post_config(apr_pool_t *p, apr_pool_t *plog,
+                                  apr_pool_t *ptemp, server_rec *s)
+     void *data;
+     const char *userdata_key = "my_module_init";
+ 
+     /* userdata not set on 1st post_config execution. */
+     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;
+     }
+ }}}
+ 

Reply via email to