httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug MacEachern <do...@covalent.net>
Subject Re: cvs commit: apache-2.0/src/main http_core.c http_protocol.c util_filter.c
Date Thu, 14 Sep 2000 19:29:57 GMT
On Thu, 14 Sep 2000 rbb@covalent.net wrote:
 
> -1 This is very bad.  This means that there are now two ways to add
> filters to the stack, and filters will never know which one was
> used.  That means EVERY filter that needs to have it's own data pointer in
> the filter, needs this code at the top of the function (or wherever it
> creates the structure):
> 
>     if (!f->ctx) {
>         apr_palloc(p, sizeof(foo));
>     }
> 
> it is much cleaner for filter writers to just always do
> 
>     apr_palloc(p, sizeof(foo));
> 
> because there will never be any memory there when they are first called.

no, f->ctx checking only needs to be there for modules that use a ctx,
right?  and, f->ctx isn't always something allocated from an apache pool.
what's the difference if the ctx is set when calling ap_add_filter()
vs. some other time?  if what you're saying is really a problem, then why
bother having f->ctx at all?
for filters that don't use ctx, they can just ignore it.  for those that
do, e.g. Perl:

CV *cv;
if (f->ctx) {
    cv = (CV*)f->ctx; /* already have a reference to the subroutine */
}
else {
    /* lookup a reference to the subroutine using the filter name */
    cv = perl_get_cv(f->frec->name, FALSE);
}

...
perl_call_sv((SV*)cv, ...)
...

again, there are cases when the ctx is only know when ap_add_filter() is
called, e.g. at request time a Perl module calls:

$r->add_filter($name, sub { my $filter = shift ...});

if mod_perl can't save the anonymous 'sub {}' reference (which has no
name for get_cv() to do a lookup) into the ctx when it calls add_filter(),
then mod_perl needs to maintain it's own table, which is much more painful
than simply checking if (f->ctx) {} else {}


Mime
View raw message