httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Schaefer <>
Subject Re: mod_include_post...the saga continues
Date Fri, 27 Aug 2004 18:02:18 GMT
"Anthony Wells" <> writes:

> Nick had recommend that I use the request_config field to store the pointer
> to the bucket brigade copy.


> I have done so, but when I go to retrieve the brigade and try to get it's
> length, I get some nasty segmentation faults.  Also, I have removed any
> other code from my module that uses r->request_config, so it should be
> untouched as far as I can see.
> My question is, Is the bucket brigade or buckets in my "copy" being cleaned
> up to soon?

Not that I can see from what you've posted.  Are you sure the bbcopy
your output filter receives from ap_get_module_config isn't NULL?

> Here is my code in my InputFilter module:
> 		apr_bucket_brigade *bbcopy;
> 		bbcopy = apr_brigade_create(f->c->pool, f->c->bucket_alloc);
> 		apr_bucket *e;                 
>     		for (e = APR_BRIGADE_FIRST(bb);
> 		     e != APR_BRIGADE_SENTINEL(bb);
> 		     e = APR_BUCKET_NEXT(e))
>     		{ 
> 	        apr_bucket *c;
>         	  apr_bucket_copy(e, &c);
>         	  APR_BRIGADE_INSERT_TAIL(bbcopy, c);

My only crticism of this code is that you're recreating bbcopy each
time your input filter is invoked (assuming that's where it is).  
What you should be doing is using the filter's ctx slot to
hold a pointer to your bbcopy brigade, append the copied buckets to 
that.  The opening logic in your filter would look like

    apr_bucket_brigade *bb_copy;

    if (!f->ctx)
        f->ctx = bb_copy = apr_brigade_create(f->r->pool, f->c->bucket_alloc);
        bb_copy = f->ctx;


> Here is my code in my OutputFilter module:
> 	apr_bucket_brigade *bbcopy;
> 	bbcopy = ap_get_module_config(r->request_config, &include_module);

Check that this is non-NULL (yes it can happen).

Joe Schaefer

View raw message