cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Info request about the zero copy interface

From: Legolas <legolas558_at_email.it>
Date: Thu, 01 Dec 2005 10:19:11 +0100

Daniel Stenberg ha scritto:

> On Thu, 1 Dec 2005, Legolas wrote:
>
>> My idea is to give libcurl an RWops object (which is an input or
>> output stream), and then libcurl will call its assigned methods to
>> make any read/write operation. I know this is a radical change, but
>> it may speed up a lot every operation.
>
>
> "every" ? What other operations than read or write do you think it needs?
>
I don't understand your question, however passing libcurl an object with
assigned read/write methods (and others if needed) will avoid the file
writing or reading memory copy bottleneck (data would not be cached into
memory and passed to libcurl, but directly read/written from libcurl
itself through the read/write method).

1) Example of possible libcurl source snippet (WRITE operation, maybe a
download):
------------------------------------------
RWops *rw;
void *socket_buffer_recv;
int size, blocks;
...
    /* ZERO COPY: RWops object will write to file, memory, or whatever
it really is behind the RWops */
    if (rw->write(rw, socket_buffer_recv, size, blocks) != blocks) {
          /* eventual cleanup code */
          return CURLE_WRITE_ERROR;
    }
...
------------------------------------------

2) Example of possible libcurl source snippet (READ operation, maybe an
upload):
------------------------------------------
RWops *rw;
void *socket_buffer_send;
int size, blocks;
...
    /* ZERO COPY: RWops object will read from file, memory, or whatever
it really is behind the RWops */
    if (rw->read(rw, socket_buffer_send, size, blocks) != blocks) {
          /* eventual cleanup code */
          return CURLE_READ_ERROR;
    }
...
------------------------------------------

I think this is really the best way to create an actual zero copy
interface, in case (1, WRITE) the eventual subsequent
buffers needed would be handled automatically by the RWops object.

Such an implementation would allow, if you look further, to send libcurl
inputs to libcurl outputs & reverse, because
as I have already told you the RWops object should also encapsulate an
curl-type stream.
Received on 2005-12-01