httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cliff Woolley <>
Subject Re: is it possible to mark buckets to be copied only when to be set-aside?
Date Wed, 19 May 2004 13:33:01 GMT
On Wed, 19 May 2004, William A. Rowe, Jr. wrote:

> It's a bug in mod_xslt, if that module trys to set aside a transient bucket.

Huh?  No it isn't.  Half of the reason setaside() even exists is to handle
transient buckets.

static apr_status_t transient_bucket_setaside(apr_bucket *b, apr_pool_t *pool)
    b = apr_bucket_heap_make(b, (char *)b->data + b->start, b->length, NULL);
    if (b == NULL) {
        return APR_ENOMEM;
    return APR_SUCCESS;

In other words, setting aside a transient bucket does exactly what you
want -- it copies the data into a new buffer allocated on the heap.  So I
think mod_perl is doing the right thing by using a transient bucket here,
and I think mod_xslt is doing the right thing by calling setaside.
However, setaside is supposed to be used prior to returning from any
function in the current call stack, not just when you want to keep a
bucket past the end of the current request.

In other words, if any filter wants to keep a bucket and return to its
caller rather than passing that bucket to the next filter, it should call
setaside on that bucket.  Failing to do so won't be a problem for most
bucket types, but it most assuredly WILL be a problem for transient
buckets, by the definition of "transient": the storage behind a transient
bucket is only guaranteed to exist and have the desired data in it until
you return back into the function that created that bucket.

Note: ap_save_brigade() handles the setaside and brigade concatenation for
you.  I suspect there are a number of places in the code that we are
incorrectly calling APR_BRIGADE_CONCAT() instead of ap_save_brigade().
That's bug city right there.


View raw message