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 David Wortham <dj...@gmail.com> on 2007/02/10 00:54:24 UTC

Merge function not called when I would expect it to

Thanks to all of those who responded to my whitescreen/segfault problems.
It turns out I was 'allocing' memory for the newly created dir_cfg and for
an array of rbl_handler pointers, but not for each individual rbl_pointer
structure that the rbl_handler pointers pointed to.

Now that that's fixed, I am seeing something a little unexpected and am not
seeing something expected.

The relevant directory structure is shown below:
/* start httpd.conf excerpt */
<Directory ~ "/home/**/dev_***/(htdocs)"> # htdocs root
# ...
<Directory ~ "/home/**/dev_***/images"> # images root... given permissions
similar to htdocs
# ...
<Directory ~ "/home/**/dev_***/images/icons"> # I want the dir_cfg for this
directory to be created after a merge between it and it's FileSystem parent
(as defined just above)
/* end httpd.conf excerpt */

As I understand it, the dir_cfg_merge function should be called (assuming it
is defined and the function pointer is set in the module array) anytime one
directory is a child of a previously defined directory.

What I do see during httpd startup (you are seeing my debug outputs printed
to STDERR):
/* start merge function trace */
entered my_create_svr_conf for svr: "(null)"
entered my_create_dir_conf for dir: "(null)"

entered my_create_dir_conf for dir: "(null)"
entered my_create_svr_conf for svr: "127.0.0.1"

entered my_create_dir_conf for dir: "/home/dj/dev_unspam/(htdocs)"
entered my_create_dir_conf for dir: "/home/dj/dev_unspam/images"
entered my_create_dir_conf for dir: "/home/dj/dev_unspam/images/icons"

entered my_merge_svr_cfg
- parentsvr->hostname               = (null)
- childsvr->hostname                  = "127.0.0.1"
entered my_merge_dir_cfg
- parentdir->dirpath                  = (null)
- childdir->dirpath                    = (null)
/* end merge function trace */
(the "->dirpath" and "->hostname" are strings stored in the dir_cfg and
svr_cfg structs and are set during the "my_create_**r_cfg" functions.  I
have debug statements ensuring that these are set correctly in the **r_cfg
structs at the end of the "my_create_**r_cfg" function.)

I have tried the usual things:
- moving/decentralizing the configuration from "httpd.conf" into ".htaccess"
files stored in each directory (are those necessarily parsed at server
startup?)
- dumping the contents of the dir_cfg (and svr_cfg) structs to STDERR to see
if there is any other data which could potentially identify the
directory/server

My questions are:
- why is the merge_dir_cfg function being called with a blank (initialized
but never set) dir_cfg struct (at the end of the httpd process startup
trace)?
- why isn't merge_dir_cfg being called "between" the ".../images" and
".../images/icons/" dir_cfgs?  Why wouldn't these two directories need to be
set?
- are .htaccess files read immediately after the httpd.conf?  (my coworkers
seem to think they are read [and hence new dir_cfg structs are created]
during each HTTP request)


Any insight into the
(1) call order and call triggers for dir_cfg merge functions,
(2) differences between .htaccess and http.conf with regards to creating and
merging dir_cfgs, and
(3) differences between .htaccess and http.conf with regards to when each
one is read/parsed (during the life of the httpd process) and what effect
that has on making/changing cir_cfgs
would be very much appreciated.

Thanks,
Dave

Re: Merge function not called when I would expect it to

Posted by David Wortham <dj...@gmail.com>.
I think I was able to answer my own question(s).

This link got me curious:
http://www.f-m-c.org/projects/apache/html/3_3Extending_Apache.html

I read what seemed to say that the merging of directories was done at the
beginning of the handling of a request.  I re-worked my debug code to output
to a logfile rather than STDERR (because STDERR is lost once the child
processes are created... and is therefore not useful for debugging after
startup).

In fact, it appears that dir_cfgs are stored by the parent process (and
given to the child processes when those are created).  Merging of dir_cfgs
appears to happen at the beginning of a response handling.  This seems to
explain how .htaccess files can be read both at server startup and at the
beginning of every request.

It appears that my merge function works now.


Dave