Return-Path: Delivered-To: apmail-new-httpd-archive@apache.org Received: (qmail 48526 invoked by uid 500); 14 Apr 2000 21:56:47 -0000 Mailing-List: contact new-httpd-help@apache.org; run by ezmlm Precedence: bulk X-No-Archive: yes Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list new-httpd@apache.org Received: (qmail 48510 invoked from network); 14 Apr 2000 21:56:45 -0000 X-Authentication-Warning: koj.rkbloom.net: rbb owned process doing -bs Date: Fri, 14 Apr 2000 14:57:52 -0400 (EDT) From: rbb@covalent.net X-Sender: rbb@koj.rkbloom.net To: new-httpd@apache.org Subject: Re: I/O filtering in 2.0 In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N 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 -------------------------------------------------------------------------------