[4.1] 8dc7483 Rewrite the H1 header fetch without SES_Rx(), this makes it simpler.

Poul-Henning Kamp phk at FreeBSD.org
Fri Sep 4 15:54:54 CEST 2015


commit 8dc74833d2bad4ce004f8dd7e78e9b8d6ddc5094
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Aug 17 06:57:58 2015 +0000

    Rewrite the H1 header fetch without SES_Rx(), this makes it simpler.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 6a2b047..648dad4 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -979,7 +979,6 @@ enum htc_status_e {
 void SES_RxInit(struct http_conn *htc, struct ws *ws,
     unsigned maxbytes, unsigned maxhdr);
 void SES_RxReInit(struct http_conn *htc);
-enum htc_status_e SES_Rx(struct http_conn *htc, double tmo);
 enum htc_status_e SES_RxStuff(struct http_conn *, htc_complete_f *,
     double *t1, double *t2, double ti, double tn);
 
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 8333123..3d23c7c 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -189,32 +189,6 @@ SES_RxReInit(struct http_conn *htc)
 	*htc->rxbuf_e = '\0';
 }
 
-/*--------------------------------------------------------------------
- * Receive more HTTP protocol bytes
- */
-
-enum htc_status_e
-SES_Rx(struct http_conn *htc, double tmo)
-{
-	int i;
-
-	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
-	AN(htc->ws->r);
-	AZ(htc->pipeline_b);
-	AZ(htc->pipeline_e);
-	i = (htc->ws->r - htc->rxbuf_e) - 1;	/* space for NUL */
-	if (i <= 0)
-		return (HTC_S_OVERFLOW);
-	i = VTCP_read(htc->fd, htc->rxbuf_e, i, tmo);
-	if (i == -2)
-		return (HTC_S_TIMEOUT);
-	if (i <= 0)
-		return (HTC_S_EOF);
-	htc->rxbuf_e += i;
-	*htc->rxbuf_e = '\0';
-	return (HTC_S_MORE);
-}
-
 /*----------------------------------------------------------------------
  * Receive a request/packet/whatever, with timeouts
  *
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index ca1df5a..1b6ceb4 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -137,7 +137,6 @@ V1F_FetchRespHdr(struct busyobj *bo)
 {
 
 	struct http *hp;
-	enum htc_status_e hs;
 	int first, i;
 	struct http_conn *htc;
 
@@ -160,23 +159,22 @@ V1F_FetchRespHdr(struct busyobj *bo)
 
 	first = 1;
 	do {
-		hs = SES_Rx(htc, 0);
-		if (hs == HTC_S_MORE)
-			hs = HTTP1_Complete(htc);
-		if (hs == HTC_S_OVERFLOW) {
-			WS_ReleaseP(htc->ws, htc->rxbuf_b);
+		i = (htc->ws->r - htc->rxbuf_e) - 1;	/* space for NUL */
+		if (i <= 0) {
 			bo->acct.beresp_hdrbytes +=
 			    htc->rxbuf_e - htc->rxbuf_b;
+			WS_ReleaseP(htc->ws, htc->rxbuf_b);
 			VSLb(bo->vsl, SLT_FetchError,
 			    "http %sread error: overflow",
 			    first ? "first " : "");
 			htc->doclose = SC_RX_OVERFLOW;
 			return (-1);
 		}
-		if (hs == HTC_S_EOF) {
-			WS_ReleaseP(htc->ws, htc->rxbuf_b);
+		i = read(htc->fd, htc->rxbuf_e, i);
+		if (i <= 0) {
 			bo->acct.beresp_hdrbytes +=
 			    htc->rxbuf_e - htc->rxbuf_b;
+			WS_ReleaseP(htc->ws, htc->rxbuf_b);
 			VSLb(bo->vsl, SLT_FetchError, "http %sread error: EOF",
 			    first ? "first " : "");
 			htc->doclose = SC_RX_TIMEOUT;
@@ -187,7 +185,10 @@ V1F_FetchRespHdr(struct busyobj *bo)
 			VTCP_set_read_timeout(htc->fd,
 			    htc->between_bytes_timeout);
 		}
-	} while (hs != HTC_S_COMPLETE);
+		htc->rxbuf_e += i;
+		*htc->rxbuf_e = '\0';
+	} while (HTTP1_Complete(htc) != HTC_S_COMPLETE);
+
 	WS_ReleaseP(htc->ws, htc->rxbuf_e);
 
 	hp = bo->beresp;



More information about the varnish-commit mailing list