httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@lnd.com>
Subject RE: PLEASE READ: Filter I/O
Date Fri, 23 Jun 2000 17:30:02 GMT
> From: Greg Stein [mailto:gstein@lyra.org]
> Sent: Friday, June 23, 2000 5:19 AM
> 
> On Thu, Jun 22, 2000 at 08:29:01PM -0700, Greg Stein wrote:
> > On Fri, Jun 23, 2000 at 03:33:05AM +0100, Tony Finch wrote:
> >...
> > > I do wonder, Greg, how your scheme avoids excessive 
> copying between
> > > each filter layer...
> 
> Crap. I didn't answer that last part :-) ... here goes:
> 
> Each filter function is defined to take a pointer/length 
> pair. That data is
> from the "content generator" or it is from a previous filter. 
> That ptr/len
> pair can be passed directly to the next layer without copying.
> 
> For example:
> 
> ap_status_t my_filter_callback(ap_layer_t *layer, const void 
> *buf, size_t len)
> {
>     ap_lwrite(layer, buf, len);
>     return APR_SUCCESS;
> }
> 
> Kind of a dumb, no-op filter :-), but it shows how data doesn't have to be
> copied. Of course, the filter can parse stuff out, send portions, etc.
> Sending a portion doesn't require copying:
> 
>     ap_lwrite(layer, (const char *)buf + 5, 5);
> 
> 
> Is there something else that you were thinking of, or did I answer the
> question?

What about passing buf, buflen, alloc, alloclen on?  That way we don't need
to do any realloc if we are growing the buffer by 10 chars and the last 
filter just chopped the buffer by 50 chars?  (Suppose this would apply to
hook based as well):

ap_status_t my_filter_callback(ap_layer_t *layer, const void 
					 *buf, size_t len)
					 *abuf, size_t alen) {
     ap_lwrite(layer, buf + 5, len - 5, abuf, alen);
     return APR_SUCCESS;
}

would be the simple example of stripping of 5 bytes.  But this sounds
like a hook-based link-list to me (since ap_lwrite needs to parse where
layer is in the stack and kick to the next), rather than a simple hook
based where 

ap_status_t my_filter_callback(ap_layer_t **layer, const void 
					 *buf, size_t len)
					 *abuf, size_t alen) {
     /* **layer is us */
     return ap_lwrite(layer + 1, buf + 5, len - 5, abuf, alen);
}


Mime
View raw message