httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John David Duncan <>
Subject Per-server config issue
Date Fri, 23 Feb 2007 17:46:41 GMT

I am seeing a very strange issue with per-server config processing.

Consider a config directive:

{  "ServerThing",
     (CMD_HAND_TYPE) config_server_thing,
     RSRC_CONF,      TAKE1,
     "For Testing"

I have a struct to hold the per-server configuration (struct srv).   
An instance of struct srv gets allocated and initialized by an init  
function, and then when Apache sees "ServerThing foo" in httpd.conf,  
it calls config_server_thing:

const char *config_server_thing(cmd_parms *cmd, void *m, char *arg) {


So far, so good.  But here's the problem:  In this function, I should  
be able to cast the pointer, m, back to the struct srv that was  
initialized earlier.

  srv_conf = (struct srv *) m;

But after lots of debugging, I find that:

   1) The pointer m is not equal to the pointer that was returned  
from the initialization function.
   2) m does not hold a copy of the data structure that was initialized.
   3) And m is also not equal to the value of
        ap_get_module_config(cmd->server->module_config, &my_module)

Finally, as a work-around, I decided to use:
   srv_conf = (struct srv *) ap_get_module_config(cmd->server- 
 >module_config, &my_module);
instead of:
   srv_conf = (struct srv *) m;

So, what's the problem?  Well...
  * It's not a "merge" problem.  (I implemented a merging function  
just in case, but that never gets called).
  * It's not the vhost issue described on pg. 574 of "Writing Apache  
Modules with Perl and C" where your init function might never get  
called (the init function *is* called, and there are no virtual hosts  
at all in this config file)
  * It's not a bug with one particular release of Apache -- I see the  
same behavior in both 1.3.33 and 2.2.3.
  * I can't find any obvious problem with my code (all of my per- 
directory config stuff works perfectly).

So, I wonder: is my work-around safe?
Should I file a bug?
Is there someone in particular I should ask for help?



View raw message