httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <>
Subject Re: sub_req_lookup_simple bug?
Date Mon, 31 Mar 1997 06:07:24 GMT
Excuse me while I talk to myself.  I'm wallowing in the depths of
undocumented API hell.

I've decided that the omission of location_walk in sub_req_lookup_file is
deliberate.  But the lack of a file_walk in sub_req_lookup_simple is still
a bug.

The sub_req_lookup_simple optimization is totally broken because it makes
undocumented assumptions about the API.  For example, if a module twiddles
its r->request_config, or r->notes, or many other request_rec structures
during either the type_checker or run_fixups phases then it will be
*changing the values of the parent request*.  sub_req_lookup_simple does
a "*rnew = *r" and puts no effort into dealing with the shared pointers
to structures and such.

Unfortunately mod_dir and mod_negotiation make pretty heavy use of
sub_req_lookup_simple (at least indirectly via sub_req_lookup_file)
because they both do potentially many same directory lookups.  I don't
care about mod_dir myself because I don't think FancyIndexes is something
you use on a high-end server... but negotiation would suck if it became

The only reason it works at the moment is probably luck and the fact that
none of our stock modules seem to do tweaking that would trigger this


On Sun, 30 Mar 1997, Dean Gaudet wrote:

> Aie!  Ok I dug more.  I'm sorry I did :)
> It definately is a bug to not call file_walk and location_walk, but I'm
> having trouble thinking of a fix that doesn't suck performance.  It's a
> pig because of how mod_dir and mod_negotiation will create lots o' sub
> requests all through sub_req_lookup_file, expecting sub_req_lookup_simple
> to speed up the "simple" cases.
> I was thinking of just folding in the _simple case into _file by avoiding
> directory_walk, but I wasn't sure how to figure out if the call to
> file_walk/location_walk changed the access permissions requiring the access
> checks to be redone.  Essentially the only heuristic I could use is
> "were any <Files> or <Location> sections valid?  If so then redo the
> access checks".  I guess I just need some way to get that result from
> file_walk and location_walk.
> The bugs so far:
> - sub_req_lookup_file doesn't call location_walk and sub_req_lookup_simple
>     doesn't call location_walk or file_walk.
> - sub_req_lookup_simple doesn't copy the request_time, or a few
>     other fields.  Might not matter much unless a sub-request of a simple
>     sub-request is done.
> - sub_req_lookup_file doesn't build rnew->uri but sub_req_lookup_simple
>     does.  So, for example, #include file="x" and #include file="a/x"
>     behave quite differently.  Yeah we say #include file is deprecated.
>     But I'm not sure that the other uses of sub_req_lookup_file are
>     unaffected by this.
> - handle_multi not merging headers properly, and other little ones in
>     mod_negotiation (I'll post a separate [PATCH] message for these)
> - (not a bug, just a performance note):  adding a stat() result cache
>     could be a win -- check_symlinks and get_path_info conspire to stat()
>     the same file 4 times in the config I'm working with, and directories
>     get stat()d many many times.
> BTW I tried replacing sub_req_lookup_file with sub_req_lookup_uri in
> mod_negotiation but that doesn't work properly when there's PATH_INFO
> involved.  (i.e. cp /cgi-bin/printenv /cgi-bin/t.cgi, and access
> /cgi-bin/t/foobar, it'll loop looking at /cgi-bin/t/t/t/t/t.../t/foobar
> until it gets to MAXPATHLEN or something like that)
> Dean
> P.S. All this just because I want to be able to turn tracking cookies on
> and off by file extension and I decided to use <Files> instead of inventing
> a new syntax.  :(
> On Fri, 28 Mar 1997, Roy T. Fielding wrote:
> > >sub_req_lookup_file bypasses most of its work if there is no /
> > >in the new_file.  But there's no file_walk or location_walk inside
> > >sub_req_lookup_simple.  I'd believe the / heuristic when only <Directory>
> > >and .htaccess are involved, but I'm pretty sure we now need to call
> > >file_walk and location_walk.
> > 
> > Sounds reasonable to me.  OTOH, I haven't a clue as to how <Directory>,
> > <Location>, and <File> interact in practice -- it was hard enough just
> > trying to figure out how directory_walk alone worked, and I've long
> > since forgotten that.  We have no documentation on it (not even Ben's book
> > covers the subject).
> > 
> > .....Roy
> > 

View raw message