httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@covalent.net
Subject Re: I/O filtering in 2.0
Date Fri, 14 Apr 2000 18:57:52 GMT
On Fri, 14 Apr 2000 rbb@covalent.net wrote:

> 
> > > -            rv = ap_bwrite(r->connection->client, addr, n, &w);
> > > +            copy = ap_pcalloc(r->pool, n); 
> > > +            ap_cpystrn(copy, addr, n); 
> > 
> > Use memcpy() not ap_cpystrn(). The latter is only for strings. Whenever
> > you know the length of the input, string or not, then memcpy() should be
> > used. It will always be faster.
> 
> > Can't do this. The string that was passed to us is marked "const". It may
> > really be a const!
> > 
> > static const char * const signature = "gooblefarg";
> > ...
> >    ap_rputs(signature, r);
> 
> Good point.
> 
> > > @@ -2831,3 +2848,6 @@
> > >  			 NULL)
> > >  IMPLEMENT_HOOK_RUN_FIRST(unsigned short,default_port,(const request_rec *r),
> > >  			 (r),0)
> > > +IMPLEMENT_HOOK_VOID(filter,
> > > +                    (request_rec *r, char *str, int len),
> > > +                    (r, str, len))
> > 
> > This modifies the value in place. It doesn't make any provision for
> > altering the length. Modifying in place implies making a copy of the data
> > before passing it to the hook. Even then, you may not have enough buffer
> > for the cases where the output is expanded.
> 
> I'll say it again, easy first pass to show the basic outline of the code,
> obviously the ability to extend the buffer's size is absolutely
> necessary.  That would have been added later.

Actaully, the easiest way to solve all of this is to not use a char *,
but instead to create an IOL that deals with a buffer.  Then, just before
calling the run_filters list, we copy into the IOL, and then pass the IOL
around.  This allows the buffer to be resized pretty easily.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Mime
View raw message