You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by sterling <st...@covalent.net> on 2001/11/15 03:10:59 UTC

[PATCH] OLD_WRITE filter assumes it is first in the output filters list

Hi -

I am not too familiar with the OLD_WRITE filter, but I have run into an
interesting situation.  I want to ensure that my filter is before any of
the FTYPE_CONTENT filters.  The only way to do this is to make mine
FTYPE_CONTENT-1.  However, OLD_WRITE assumes (since it is set as
FTYPE_CONTENT-1) that it is the first filter in output_filters (and then
assumes that in fact it is the first one without checking).

Maybe OLD_WRITE should be set to 0 (or AP_FTYPE_FIRST or something) so you
can have more fine grained filter ordering.   Here is a patch that
implements that (and also gets rid of an assumption in buffer_output).

As I said, not sure if this is the right fix, any suggestions (MAYBE an
FTYPE_FIRST instead of FTYPE_CONTENT-1)?

thanks

sterling

Index: server/core.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/core.c,v
retrieving revision 1.88
diff -u -r1.88 core.c
--- server/core.c	2001/11/08 14:29:36	1.88
+++ server/core.c	2001/11/15 00:46:12
@@ -3301,7 +3301,7 @@
     ap_register_output_filter("SUBREQ_CORE", ap_sub_req_output_filter,
                               AP_FTYPE_CONTENT);
     ap_old_write_func = ap_register_output_filter("OLD_WRITE",
-                                   ap_old_write_filter, AP_FTYPE_CONTENT - 1);
+                                   ap_old_write_filter, 0);
 }

 AP_DECLARE_DATA module core_module = {
Index: server/protocol.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/protocol.c,v
retrieving revision 1.51
diff -u -r1.51 protocol.c
--- server/protocol.c	2001/11/07 05:41:22	1.51
+++ server/protocol.c	2001/11/15 00:46:12
@@ -1069,8 +1069,8 @@
     if (f == NULL) {
         /* our filter hasn't been added yet */
         ctx = apr_pcalloc(r->pool, sizeof(*ctx));
-        ap_add_output_filter("OLD_WRITE", ctx, r, r->connection);
-        f = r->output_filters;
+        f = ap_add_output_filter("OLD_WRITE", ctx, r, r->connection);
+        AP_DEBUG_ASSERT(f);
     }

     /* if the first filter is not our buffering filter, then we have to


Re: [PATCH] OLD_WRITE filter assumes it is first in the output filters list

Posted by Ryan Bloom <rb...@covalent.net>.
On Thursday 15 November 2001 12:18 am, sterling wrote:
> On Wed, 14 Nov 2001, Ryan Bloom wrote:
> > On Wednesday 14 November 2001 06:10 pm, sterling wrote:
> > > Hi -
> > >
> > > I am not too familiar with the OLD_WRITE filter, but I have run into an
> > > interesting situation.  I want to ensure that my filter is before any
> > > of the FTYPE_CONTENT filters.  The only way to do this is to make mine
> > > FTYPE_CONTENT-1.  However, OLD_WRITE assumes (since it is set as
> > > FTYPE_CONTENT-1) that it is the first filter in output_filters (and
> > > then assumes that in fact it is the first one without checking).
> > >
> > > Maybe OLD_WRITE should be set to 0 (or AP_FTYPE_FIRST or something) so
> > > you can have more fine grained filter ordering.   Here is a patch that
> > > implements that (and also gets rid of an assumption in buffer_output).
> > >
> > > As I said, not sure if this is the right fix, any suggestions (MAYBE an
> > > FTYPE_FIRST instead of FTYPE_CONTENT-1)?
> >
> > The OLD_WRITE filter is a CONTENT filter, so I am leaving it with that
> > type, but to allow some space to manuver, I changed it to FTYPE_CONTENT -
> > 10.
>
> which happens to be 0 (what my patch had)

Yeah, but the details are slightly different.  By using FTYPE_CONTENT - 10,
I leave it as a CONTENT filter, instead of having to create a special filter type
for filters that have to be absolutely first.  All filters are registered according to 
what they do, not where they belong in the filter stack.

Ryan

______________________________________________________________
Ryan Bloom				rbb@apache.org
Covalent Technologies			rbb@covalent.net
--------------------------------------------------------------

Re: [PATCH] OLD_WRITE filter assumes it is first in the output filters list

Posted by sterling <st...@covalent.net>.
On Wed, 14 Nov 2001, Ryan Bloom wrote:

> On Wednesday 14 November 2001 06:10 pm, sterling wrote:
> > Hi -
> >
> > I am not too familiar with the OLD_WRITE filter, but I have run into an
> > interesting situation.  I want to ensure that my filter is before any of
> > the FTYPE_CONTENT filters.  The only way to do this is to make mine
> > FTYPE_CONTENT-1.  However, OLD_WRITE assumes (since it is set as
> > FTYPE_CONTENT-1) that it is the first filter in output_filters (and then
> > assumes that in fact it is the first one without checking).
> >
> > Maybe OLD_WRITE should be set to 0 (or AP_FTYPE_FIRST or something) so you
> > can have more fine grained filter ordering.   Here is a patch that
> > implements that (and also gets rid of an assumption in buffer_output).
> >
> > As I said, not sure if this is the right fix, any suggestions (MAYBE an
> > FTYPE_FIRST instead of FTYPE_CONTENT-1)?
>
> The OLD_WRITE filter is a CONTENT filter, so I am leaving it with that type,
> but to allow some space to manuver, I changed it to FTYPE_CONTENT - 10.

which happens to be 0 (what my patch had)

sterling


Re: [PATCH] OLD_WRITE filter assumes it is first in the output filters list

Posted by Ryan Bloom <rb...@covalent.net>.
On Wednesday 14 November 2001 06:10 pm, sterling wrote:
> Hi -
>
> I am not too familiar with the OLD_WRITE filter, but I have run into an
> interesting situation.  I want to ensure that my filter is before any of
> the FTYPE_CONTENT filters.  The only way to do this is to make mine
> FTYPE_CONTENT-1.  However, OLD_WRITE assumes (since it is set as
> FTYPE_CONTENT-1) that it is the first filter in output_filters (and then
> assumes that in fact it is the first one without checking).
>
> Maybe OLD_WRITE should be set to 0 (or AP_FTYPE_FIRST or something) so you
> can have more fine grained filter ordering.   Here is a patch that
> implements that (and also gets rid of an assumption in buffer_output).
>
> As I said, not sure if this is the right fix, any suggestions (MAYBE an
> FTYPE_FIRST instead of FTYPE_CONTENT-1)?

The OLD_WRITE filter is a CONTENT filter, so I am leaving it with that type,
but to allow some space to manuver, I changed it to FTYPE_CONTENT - 10.

Ryan

______________________________________________________________
Ryan Bloom				rbb@apache.org
Covalent Technologies			rbb@covalent.net
--------------------------------------------------------------