Google Groups Home
Help | Sign in
Message from discussion upload handling
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
ry  
View profile
 More options Apr 1, 1:45 pm
From: ry <ry.d...@googlemail.com>
Date: Tue, 1 Apr 2008 10:45:50 -0700 (PDT)
Local: Tues, Apr 1 2008 1:45 pm
Subject: Re: upload handling
Hi Adam,

> It seems that EBB_BUFFERSIZE controls the behavior of two unrelated things:

That's correct. The initial continuous block of memory that the
request header is stored on. ebb sends pointers to each header field
and value which reference the buffer. Only the header needs to be on a
continuous block of memory, the body could be broken up. However Ebb
does not have support (yet) for growing this buffer - instead it
writes to file if the request is too big for it.

> a) the buffer size for reads.  This buffer must be set large enough that it
> can't be filled before the next time libev calls on_client_readable,
> correct?  If the buffer gets filled all the way (client->read ==
> EBB_BUFFERSIZE) you throw an error, because we've probably lost some data
> that didn't fit in the buffer.

No. Ebb tries to get the header onto the buffer. Once the header is
on, it checks the content-length - if there is enough room it puts the
rest of the request onto the buffer, otherwise spawns a thread and
writes the whole request to file. It will error out if the header is
larger than EBB_BUFFERSIZE. However, the buffer is sufficiently large
that this shouldn't happen for any normal request.

> b) Cut-off for mem versus disk. Once the request is finished, EBB_BUFFERSIZE
> controls which requests get saved to disk.  In this case, anything larger
> than 40KB gets tossed in a thread which saves it to disk.

Once the header is read, and Ebb determines the content-length +
header_size > EBB_BUFFERSIZE it
1) spawns a thread
2) opens a tempfile
3) writes the part of the request body that was already in client-
>request_buffer to the file

4) reads blocks from the socket and writes them to the tempfile.

> Please correct me on any errors, but it seems like even large uploads aren't
> written to disk until they've been completely stored into memory(or swap?).

No, that wouldn't be good. Large requests are written as they come in.

> I say this because read_body_into_file is only called after
> client_finished_parsing==true and after we have a total_request_size.  Is
> that assessment correct, or am I mis-reading your code?

the parser only handles the header, not the body.

The obvious improvement that can be done is allowing larger memory
uploads. I haven't done this yet because of the all the memory
management that will be required. Perhaps an easy little buffer
library could be made with the aid of glib to allow for this
improvement?

ry


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google