Hi Mark,

On Tue, Aug 07, 2012 at 10:23:08AM +0800, Mark Green wrote:
> Hi,
> 
> I read the source code,
> but don't quit understand the to_forward of buffer.
> what does it exactly mean? what data it refers to?

to_forward is the amount of bytes that can still be transferred from
the socket attached to the input of the buffer, to the socket which
is attached to the output of the buffer, without waking the task up
nor the analyzers. For instance, when parsing a chunk-encoded HTTP
response, to_forward will contain the size of the chunk header plus
the announced size of the chunk, so that the analyzer is woken up
later when it wants to parse next chunk size.

> when to increase and when to decrease?

It is increased by the application layer (any of the http_* functions
for instance), and is decreased each time some data are received, by
the amount of data received, unless it is already set to the infinite
value (eg: in TCP mode or for a tunnel).

> what is the relation between it and send_max?

send_max is automatically refilled up to the min of to_forward and the
buffer's length so that the maximum possible amount of bytes in the
buffer are able to be forwarded on the other size.

You can check all this in sock_raw_read() if you need more details.
As I told you last time, if you're working on adding new features,
it's fine if you get the general idea right now, but since the buffer
management and connection handling are currently undergoing major
changes in order to later support SSL and server-side keep-alive,
you should avoid developing too much code that would become difficult
to port until dev12 is out.

Regards,
Willy


Reply via email to