httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christina Fu <fu.christ...@gmail.com>
Subject buffer in output filter
Date Fri, 04 Jan 2008 06:28:49 GMT
Hi,

Wish everyone a happy new year!

I am writing a connection type output filter and have a question about
the buffer. The filter reads a bucket, do some processing and put the
result into a stack buffer, create a transient bucket from it, add a
flush bucket and send to next filter.

Is it safe to use stack buffer (char out[8192]) here? since I added
flush bucket.

Is there any concern to flush frequently?

Performance wise, what is a good way to allocate "out" buffer? stack?
pool (what pool? if using c->pool, I was afraid it would take too much
buffer before the connection is closed and all pool memory freed)?, or
malloc? The bucket length range from a few bytes to 8K.


---------
const char *in;
apr_size_t inlen;
char out[8192];
int outlen;

//Read data from bucket
status = apr_bucket_read(bucket, &in, &inlen, APR_NONBLOCK_READ);

//process data and put into out buffer
process_data(in, inlen, out, &outlen);

//Create a transient bucket from out buffer
apr_bucket *bucket = apr_bucket_transient_create(out, outlen, 	
                             f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, bucket);

//Create a flush bucket
apr_bucket *e = apr_bucket_flush_create(f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e);

//Pass to the next filter
ap_pass_brigade(f->next, bb);
----------

Appreciate any comments. Thanks a lot.

Christina






Mime
View raw message