Mailing List Archive

r2083 - trunk/varnish-cache/bin/varnishd
Author: phk
Date: 2007-10-08 09:51:31 +0200 (Mon, 08 Oct 2007)
New Revision: 2083

Modified:
trunk/varnish-cache/bin/varnishd/cache_httpconn.c
Log:
Bail normally instead of asserting on buffer full.
Drop leading whitespace if so informed.


Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-10-08 07:50:31 UTC (rev 2082)
+++ trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-10-08 07:51:31 UTC (rev 2083)
@@ -123,7 +123,13 @@
return (i);
}

-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Receive more HTTP protocol bytes
+ * Returns:
+ * -1 error
+ * 0 more needed
+ * 1 got complete HTTP header
+ */

int
HTC_Rx(struct http_conn *htc)
@@ -132,16 +138,18 @@

CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
i = (htc->ws->r - htc->rxbuf.e) - 1; /* space for NUL */
- assert(i > 0);
- i = read(htc->fd, htc->rxbuf.e, i);
- if (i < 0) {
+ if (i > 0)
+ i = read(htc->fd, htc->rxbuf.e, i);
+ if (i <= 0) {
WS_ReleaseP(htc->ws, htc->rxbuf.b);
return (-1);
}
htc->rxbuf.e += i;
*htc->rxbuf.e = '\0';
i = htc_header_complete(&htc->rxbuf);
- if (i == 0)
+ if (i < 0)
+ htc->rxbuf.e = htc->rxbuf.b;
+ if (i <= 0)
return (0);
WS_ReleaseP(htc->ws, htc->rxbuf.e);
if (htc->rxbuf.b + i < htc->rxbuf.e) {