On Sun, Nov 23, 2003 at 11:09:47AM -0500, Jeff Trawick wrote: > Glenn wrote: > > >Should the filters mentioned above use apr_brigade_cleanup() instead? > >e.g. what happens if a handler uses ap_brigade_pass() to pass a brigade > >to a filter, say mod_ext_filter, and then calls apr_brigade_cleanup() > >and reuses the brigade? The brigade will already have been destroyed > >by mod_ext_filter, won't it? > > The caller of ap_pass_brigade() relinquishes its interest in the brigade. > The usual case is for the core output filter (server/core.c) to do the > destroy, though occasionally some other filter will do that.
Does that mean that it is incorrect to call apr_brigade_destroy() on a brigade that you have passed? There are a number of places in the code that do this. What is the benefit of relinquishing the brigade in addition to relinquishing the buckets within? IIRC, there was some discussion a long time ago about how filters MUST handle all buckets in a brigade passed to it by either passing them on or by stashing them somewhere in their ctx. That make sense to me, and seems to say that a filter does not own the brigade, or else it would be safe to just stash the brigade in its context. Is it safe for a filter to hold on to a brigade that was passed to it? I am under the impression that it is not safe to do that. What is the benefit of a apr_brigade_destroy() over apr_brigade_cleanup()? If it is not huge, I'd prefer being able to cleanup and reuse my brigade rather than needlessly allocating a new one. With regards to your patch below, does anyone use AP_NOBODY_WROTE? Is it intended to be equivalent to APR_SUCCESS, with some additional info? I haven't seen places in the code that check the return call from ap_pass_brigade checking both APR_SUCCESS and AP_NOBODY_WROTE. Those that check the return status seem only to check if rc != APR_SUCCESS. Cheers, Glenn > Index: include/util_filter.h > =================================================================== > RCS file: /home/cvs/httpd-2.0/include/util_filter.h,v > retrieving revision 1.79 > diff -u -r1.79 util_filter.h > --- include/util_filter.h 22 Aug 2003 20:40:13 -0000 1.79 > +++ include/util_filter.h 23 Nov 2003 16:07:47 -0000 > @@ -318,6 +318,7 @@ > * Pass the current bucket brigade down to the next filter on the filter > * stack. The filter returns an apr_status_t value. If the bottom-most > * filter doesn't write to the network, then ::AP_NOBODY_WROTE is returned. > + * The caller relinquishes ownership of the brigade. > * @param filter The next filter in the chain > * @param bucket The current bucket brigade > */