Return-Path: Delivered-To: apmail-apache-cvs-archive@apache.org Received: (qmail 7982 invoked by uid 500); 14 Sep 2000 19:31:08 -0000 Mailing-List: contact apache-cvs-help@apache.org; run by ezmlm Precedence: bulk X-No-Archive: yes Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list apache-cvs@apache.org Received: (qmail 7961 invoked by uid 500); 14 Sep 2000 19:31:07 -0000 Delivered-To: apmail-apache-2.0-cvs@apache.org X-Authentication-Warning: mojo.covalent.net: dougm owned process doing -bs Date: Thu, 14 Sep 2000 12:29:57 -0700 (PDT) From: Doug MacEachern To: new-httpd@apache.org cc: apache-2.0-cvs@apache.org Subject: Re: cvs commit: apache-2.0/src/main http_core.c http_protocol.c util_filter.c In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N 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 {}