From: phk Date: Fri, 19 Oct 2007 08:50:50 +0000 (+0000) Subject: Fix pipelining: don't expect the fd to become readable before we X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=edc12dd7963c924f6940bfa2ee73cfe3c4987058;p=varnish Fix pipelining: don't expect the fd to become readable before we look for complete requests. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2122 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 8d6d177c..68ce9af9 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -491,6 +491,7 @@ void HTC_Init(struct http_conn *htc, struct ws *ws, int fd); int HTC_Reinit(struct http_conn *htc); int HTC_Rx(struct http_conn *htc); int HTC_Read(struct http_conn *htc, void *d, unsigned len); +int HTC_Complete(struct http_conn *htc); #define HTTPH(a, b, c, d, e, f, g) extern char b[]; #include "http_headers.h" diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 7bb6e8b0..5fb7b0f9 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -89,9 +89,9 @@ cnt_again(struct sess *sp) assert(sp->xid == 0); - do + i = HTC_Complete(sp->htc); + while (i == 0) i = HTC_Rx(sp->htc); - while (i == 0); if (i == 1) { sp->step = STP_RECV; } else { diff --git a/varnish-cache/bin/varnishd/cache_httpconn.c b/varnish-cache/bin/varnishd/cache_httpconn.c index 8ed70c9f..5f9c0a15 100644 --- a/varnish-cache/bin/varnishd/cache_httpconn.c +++ b/varnish-cache/bin/varnishd/cache_httpconn.c @@ -123,6 +123,30 @@ HTC_Reinit(struct http_conn *htc) return (i); } +/*-------------------------------------------------------------------- + * + */ + +int +HTC_Complete(struct http_conn *htc) +{ + int i; + + CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); + i = htc_header_complete(&htc->rxbuf); + 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) { + htc->pipeline.b = htc->rxbuf.b + i; + htc->pipeline.e = htc->rxbuf.e; + htc->rxbuf.e = htc->pipeline.b; + } + return (1); +} + /*-------------------------------------------------------------------- * Receive more HTTP protocol bytes * Returns: @@ -151,18 +175,7 @@ HTC_Rx(struct http_conn *htc) } htc->rxbuf.e += i; *htc->rxbuf.e = '\0'; - i = htc_header_complete(&htc->rxbuf); - 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) { - htc->pipeline.b = htc->rxbuf.b + i; - htc->pipeline.e = htc->rxbuf.e; - htc->rxbuf.e = htc->pipeline.b; - } - return (1); + return (HTC_Complete(htc)); } int