Commit a7de7174 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

When we have some amount of a chunk header, but not all of it, we

need to read more from the fd.  The semantics we _really_ want for
that read operation is "wait until at least one char is available,
then return as many as N to us".

This can be done with a combination of system calls, but it is likely
just as cheap to just read one char at a time, so we do that.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1359 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 5e9d6b74
......@@ -113,7 +113,22 @@ fetch_chunked(const struct sess *sp, int fd, struct http *hp)
/* If we didn't succeed, add to buffer, try again */
if (q == NULL || q == buf || *q != '\n') {
xxxassert(be > bp);
i = http_Read(hp, fd, bp, be - bp);
/*
* The sematics we need here is "read until you have
* received at least one character, but feel free to
* return up to (be-bp) if they are available, but do
* not wait for those extra characters.
*
* The canonical way to do that is to do a blocking
* read(2) of one char, then change to nonblocking,
* read as many as we find, then change back to
* blocking reads again.
*
* Hardly much more efficient and certainly a good
* deal more complex than reading a single character
* at a time.
*/
i = http_Read(hp, fd, bp, 1);
if (i <= 0)
return (-1);
bp += i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment