cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: lib curl nocopy callbacks

From: Philippe Raoult <phir_at_gcu-squad.org>
Date: Fri, 17 Jan 2003 10:05:04 +0100

On Fri, 17 Jan 2003 09:42:50 +0100 (MET)
Daniel Stenberg <daniel_at_haxx.se> wrote:

> > * what is passed to the user from curl via the WRITE callbacks should be
> > allocated with the provided BUFF_ALLOC function.
>
> And I guess this alloc is performed basicly before each call to read() in
> libcurl? So that the application could for example have a large amount of
> pre-allocated buffers and hand out one at a time when libcurl asks for one.

this was exactly my idea. It would allow me to do non-blocking IO in the
WRITEDATA callback without doing any copies. This would mean zero [user] copies,
which is the best you can achieve without direct kernel support.
 
> > * this means that if the user provided a HEADERWRITE function, then the
> > header buffers *which are passed to it* will be allocated with BUFF_ALLOC
>
> Right, and if libcurl needs to realloc that block? Then it will need to do
> some kind of realloc magic...

my understanding of the curl code is :
* curl allocates a buffer(1) to receive headers.
* if it's not big enough, realloc it until it fits in
* then parse the content and send it line by line (2) to the user
(if he provided a HEADERWRITE func that is).

if we keep malloc for (1) but use the user-provided callback for (2)
there should be no need to realloc. Correct me if i misunderstood
something
 
> Right. Also, we can always bounce some more ideas and fixes back and forth
> once you guys present the first working patch.

i'll try to do that soon.

Regards,
Philippe

-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com
Understand how to protect your customers personal information by implementing
SSL on your Apache Web Server. Click here to get our FREE Thawte Apache
Guide: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0029en
Received on 2003-01-17