[master] a7c8544 Introduce a function to mark pipelined data in http_conn

Poul-Henning Kamp phk at FreeBSD.org
Tue Apr 5 22:12:05 CEST 2016


commit a7c85443ab08c2da7020e7681c1371da06ff8279
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Apr 5 20:02:30 2016 +0000

    Introduce a function to mark pipelined data in http_conn

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 7df18fd..a7abad5 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -962,6 +962,7 @@ enum htc_status_e {
 };
 
 void SES_RxInit(struct http_conn *htc, struct ws *ws);
+void SES_RxPipeline(struct http_conn *htc, void *);
 enum htc_status_e SES_RxStuff(struct http_conn *, htc_complete_f *,
     double *t1, double *t2, double ti, double tn, int maxbytes);
 
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 52682aa..db04b0a 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -203,6 +203,22 @@ SES_RxInit(struct http_conn *htc, struct ws *ws)
 	*htc->rxbuf_e = '\0';
 }
 
+void
+SES_RxPipeline(struct http_conn *htc, void *p)
+{
+
+	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
+	if (p == NULL || (char*)p == htc->rxbuf_e) {
+		htc->pipeline_b = NULL;
+		htc->pipeline_e = NULL;
+		return;
+	}
+	assert((char*)p >= htc->rxbuf_b);
+	assert((char*)p < htc->rxbuf_e);
+	htc->pipeline_b = p;
+	htc->pipeline_e = htc->rxbuf_e;
+}
+
 /*----------------------------------------------------------------------
  * Receive a request/packet/whatever, with timeouts
  *
@@ -233,6 +249,8 @@ SES_RxStuff(struct http_conn *htc, htc_complete_f *func,
 
 	while (1) {
 		now = VTIM_real();
+		AZ(htc->pipeline_b);
+		AZ(htc->pipeline_e);
 		hs = func(htc);
 		if (hs == HTC_S_OVERFLOW || hs == HTC_S_JUNK) {
 			WS_ReleaseP(htc->ws, htc->rxbuf_b);
diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c
index f8ac66f..07b2fef 100644
--- a/bin/varnishd/http1/cache_http1_proto.c
+++ b/bin/varnishd/http1/cache_http1_proto.c
@@ -68,8 +68,6 @@ HTTP1_Complete(struct http_conn *htc)
 	char *p;
 
 	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
-	AZ(htc->pipeline_b);
-	AZ(htc->pipeline_e);
 
 	assert(htc->rxbuf_e >= htc->rxbuf_b);
 	assert(*htc->rxbuf_e == '\0');
@@ -193,11 +191,8 @@ http1_dissect_hdrs(struct http *hp, char *p, struct http_conn *htc,
 	}
 	if (p < htc->rxbuf_e)
 		p += vct_skipcrlf(p);
-	if (p < htc->rxbuf_e) {
-		htc->pipeline_b = p;
-		htc->pipeline_e = htc->rxbuf_e;
-		htc->rxbuf_e = p;
-	}
+	SES_RxPipeline(htc, p);
+	htc->rxbuf_e = p;
 	return (0);
 }
 
diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c
index 9d584ee..6fb8cc4 100644
--- a/bin/varnishd/proxy/cache_proxy_proto.c
+++ b/bin/varnishd/proxy/cache_proxy_proto.c
@@ -150,7 +150,7 @@ vpx_proto1(const struct worker *wrk, struct req *req)
 
 	VSL(SLT_Proxy, req->sp->vxid, "1 %s %s %s %s",
 	    fld[1], fld[3], fld[2], fld[4]);
-	req->htc->pipeline_b = q;
+	SES_RxPipeline(req->htc, q);
 	return (0);
 }
 
@@ -184,7 +184,7 @@ vpx_proto2(const struct worker *wrk, struct req *req)
 	assert(req->htc->rxbuf_e - req->htc->rxbuf_b >= 16L);
 	l = vbe16dec(req->htc->rxbuf_b + 14);
 	assert(req->htc->rxbuf_e - req->htc->rxbuf_b >= 16L + l);
-	req->htc->pipeline_b = req->htc->rxbuf_b + 16L + l;
+	SES_RxPipeline(req->htc, req->htc->rxbuf_b + 16L + l);
 	p = (const void *)req->htc->rxbuf_b;
 
 	/* Version @12 top half */
@@ -299,8 +299,6 @@ vpx_complete(struct http_conn *htc)
 	char *p, *q;
 
 	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
-	AZ(htc->pipeline_b);
-	AZ(htc->pipeline_e);
 
 	l = htc->rxbuf_e - htc->rxbuf_b;
 	p = htc->rxbuf_b;
@@ -373,10 +371,6 @@ vpx_new_session(struct worker *wrk, void *arg)
 		return;
 	}
 
-	if (req->htc->rxbuf_e ==  req->htc->pipeline_b)
-		req->htc->pipeline_b = NULL;
-	else
-		req->htc->pipeline_e = req->htc->rxbuf_e;
 	SES_SetTransport(wrk, sp, req, &HTTP1_transport);
 }
 



More information about the varnish-commit mailing list