httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ryan Bloom" <>
Subject RE: 2.0.34 - erratic behavior with autoindexes
Date Wed, 03 Apr 2002 07:32:40 GMT
Okay, I have had more time to investigate the problem.  This is kind of
strange.  First of all, I have included a patch with this post that is
absolutely 100% wrong.  The only purpose of the patch is to show the
problem, and hopefully prove that I have isolated the problem correctly.

I wasn't able to reproduce the exact problem, but I traced the problem,
and I think I saw the cause, even if I didn't see the symptoms.

The problem is that we have a main request that does NOT have the
OLD_WRITE filter.  Then we create the sub-request, which means that the
SUB_REQ_EOS filter is added without the OLD_WRITE filter.  Once we have
created the sub-request (notice we haven't run it yet), we write to the
next filter using ap_r* functions.  This will insert the OLD_WRITE
filter, and the data will be buffered in the filter.  Finally, we
actually run the sub-request.

The important thing here, is that we have never actually put the
OLD_WRITE filter into the sub-request, because it was added after we
created the sub-request.  This means that all of the data from the
sub-request is written BEFORE the pre-amble.  Because of that, we get
VERY invalid HTML.

The patch below forces mod_autoindex to insert the OLD_WRITE filter
before the sub-request is created.  As I have said, this is the WRONG
solution.  I have tested it at home, and it does force things to be
written in the correct order.  My hope is that this patch can be tested
on daedalus to ensure that it will work to solve the problem we have

_IF_ this does work, then I can think of three possible solutions to fix
the problem for real.

1)  Make sure we write the pre-amble before we create the sub-request.
The logic is possible, but it is kind of ugly.  I definitely won't have
time to write that patch until Thursday night, so I hope somebody else
can beat me to it.

2)  The second option is to modify ap_run_sub_req(), so that it detects
this case and inserts the OLD_WRITE filter for the sub-request.  This
will be exceedingly ugly, and I would prefer to not use this method.

3)  Modify mod_autoindex to not use ap_r*.  This doesn't solve the
underlying problem, but it does remove it from the release.


Index: modules/generators/mod_autoindex.c
RCS file: /home/cvs/httpd-2.0/modules/generators/mod_autoindex.c,v
retrieving revision 1.102
diff -u -d -b -w -u -r1.102 mod_autoindex.c
--- modules/generators/mod_autoindex.c  20 Mar 2002 17:41:54 -0000
+++ modules/generators/mod_autoindex.c  3 Apr 2002 07:12:53 -0000
@@ -980,6 +980,9 @@
  * instead of a text document, meaning nothing will be displayed, but
  * oh well.
+typedef struct {
+    apr_bucket_brigade *bb;
+} old_write_filter_ctx;
 static void emit_head(request_rec *r, char *header_fname, int
                       char *title)
@@ -990,6 +993,7 @@
     int emit_H1 = 1;
     const char *r_accept;
     const char *r_accept_enc;
+    old_write_filter_ctx *ctx;
      * If there's a header file, send a subrequest to look for it.  If
@@ -1003,6 +1007,9 @@
     if ((header_fname != NULL) && r->args) {
         header_fname = apr_pstrcat(r->pool, header_fname, "?", r->args,
+    ctx = apr_pcalloc(r->pool, sizeof(*ctx));
+    ap_add_output_filter("OLD_WRITE", ctx, r, r->connection);
     if ((header_fname != NULL)
         && (rr = ap_sub_req_lookup_uri(header_fname, r,

Ryan Bloom        
645 Howard St.    
San Francisco, CA 

View raw message