From b06e5c2ffee33e9e99fa803bf585e471e17f11a3 Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 8 Oct 2007 07:51:31 +0000 Subject: [PATCH] Bail normally instead of asserting on buffer full. Drop leading whitespace if so informed. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2083 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_httpconn.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_httpconn.c b/varnish-cache/bin/varnishd/cache_httpconn.c index 991fd20f..c0fd04cf 100644 --- a/varnish-cache/bin/varnishd/cache_httpconn.c +++ b/varnish-cache/bin/varnishd/cache_httpconn.c @@ -123,7 +123,13 @@ HTC_Reinit(struct http_conn *htc) 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 @@ HTC_Rx(struct http_conn *htc) 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) { -- 2.39.5