httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Wortham" <djwort...@gmail.com>
Subject Re: Per-server config issue
Date Fri, 23 Feb 2007 20:19:42 GMT
JD,
   I ran into the same problem/issue that you are observing.  I was not able
to effectively use a casted version of the (void*) parameter.
ap_get_module_config(...) works fine for me.

   To clarify some of the questions you have:
- Server config inits are run when the httpd.conf is read (at server
startup) and when .htaccess files are read (at the beginning of each
request).
- Anything created at server startup is created by the parent httpd process;
then at the end of startup, all parent config data is cloned for each child
process (explaining why you see different pointers for what you thought was
the same pointer)

This link may help you understand the Apache startup better:
http://www.f-m-c.org/projects/apache/html/3_3Extending_Apache.html

Sorry if I'm telling you something you already know, but this info would
have helped me immensely when I started module programming.

Dave





On 2/23/07, John David Duncan <jdd@mysql.com> wrote:
>
> Hi,
>
> I am seeing a very strange issue with per-server config processing.
>
> Consider a config directive:
>
> {  "ServerThing",
>      (CMD_HAND_TYPE) config_server_thing,
>      NULL,
>      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?
>
>
> Thanks,
>
> JD
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message