r1359 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Thu Apr 19 17:17:35 CEST 2007
Author: phk
Date: 2007-04-19 17:17:35 +0200 (Thu, 19 Apr 2007)
New Revision: 1359
Modified:
trunk/varnish-cache/bin/varnishd/cache_fetch.c
Log:
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.
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-04-19 14:51:23 UTC (rev 1358)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-04-19 15:17:35 UTC (rev 1359)
@@ -113,7 +113,22 @@
/* 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;
More information about the varnish-commit
mailing list