[master] d53f0f7 Convert htc->pipeline from txt to two char* pointers

Poul-Henning Kamp phk at FreeBSD.org
Sun Sep 28 19:53:46 CEST 2014


commit d53f0f7febdd7534cec775149fe081b3cad5fafb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sun Sep 28 16:42:00 2014 +0000

    Convert htc->pipeline from txt to two char* pointers

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index f3a05be..ccbf45b 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -248,7 +248,8 @@ struct http_conn {
 	unsigned		maxhdr;
 	struct ws		*ws;
 	txt			rxbuf;
-	txt			pipeline;
+	char			*pipeline_b;
+	char			*pipeline_e;
 	ssize_t			content_length;
 	enum body_status	body_status;
 	struct vfp_ctx		vfc[1];
diff --git a/bin/varnishd/cache/cache_http1_proto.c b/bin/varnishd/cache/cache_http1_proto.c
index 49047d3..04f1125 100644
--- a/bin/varnishd/cache/cache_http1_proto.c
+++ b/bin/varnishd/cache/cache_http1_proto.c
@@ -75,8 +75,8 @@ HTTP1_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *vsl,
 	htc->rxbuf.b = ws->f;
 	htc->rxbuf.e = ws->f;
 	*htc->rxbuf.e = '\0';
-	htc->pipeline.b = NULL;
-	htc->pipeline.e = NULL;
+	htc->pipeline_b = NULL;
+	htc->pipeline_e = NULL;
 }
 
 /*--------------------------------------------------------------------
@@ -88,18 +88,19 @@ HTTP1_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *vsl,
 enum http1_status_e
 HTTP1_Reinit(struct http_conn *htc)
 {
-	unsigned l;
+	ssize_t l;
 
 	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
 	(void)WS_Reserve(htc->ws, htc->maxbytes);
 	htc->rxbuf.b = htc->ws->f;
 	htc->rxbuf.e = htc->ws->f;
-	if (htc->pipeline.b != NULL) {
-		l = Tlen(htc->pipeline);
-		memmove(htc->rxbuf.b, htc->pipeline.b, l);
+	if (htc->pipeline_b != NULL) {
+		l = htc->pipeline_e - htc->pipeline_b;
+		assert(l > 0);
+		memmove(htc->rxbuf.b, htc->pipeline_b, l);
 		htc->rxbuf.e += l;
-		htc->pipeline.b = NULL;
-		htc->pipeline.e = NULL;
+		htc->pipeline_b = NULL;
+		htc->pipeline_e = NULL;
 	}
 	*htc->rxbuf.e = '\0';
 	return (HTTP1_Complete(htc));
@@ -116,8 +117,8 @@ HTTP1_Complete(struct http_conn *htc)
 	txt *t;
 
 	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
-	AZ(htc->pipeline.b);
-	AZ(htc->pipeline.e);
+	AZ(htc->pipeline_b);
+	AZ(htc->pipeline_e);
 
 	t = &htc->rxbuf;
 	Tcheck(*t);
@@ -145,8 +146,8 @@ HTTP1_Complete(struct http_conn *htc)
 	p++;
 	WS_ReleaseP(htc->ws, t->e);
 	if (p < t->e) {
-		htc->pipeline.b = p;
-		htc->pipeline.e = t->e;
+		htc->pipeline_b = p;
+		htc->pipeline_e = t->e;
 		t->e = p;
 	}
 	return (HTTP1_COMPLETE);
@@ -163,8 +164,8 @@ HTTP1_Rx(struct http_conn *htc)
 
 	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
 	AN(htc->ws->r);
-	AZ(htc->pipeline.b);
-	AZ(htc->pipeline.e);
+	AZ(htc->pipeline_b);
+	AZ(htc->pipeline_e);
 	i = (htc->ws->r - htc->rxbuf.e) - 1;	/* space for NUL */
 	if (i <= 0) {
 		WS_ReleaseP(htc->ws, htc->rxbuf.b);
@@ -191,23 +192,24 @@ HTTP1_Rx(struct http_conn *htc)
 ssize_t
 HTTP1_Read(struct http_conn *htc, void *d, size_t len)
 {
-	size_t l;
+	ssize_t l;
 	unsigned char *p;
 	ssize_t i = 0;
 
 	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
 	l = 0;
 	p = d;
-	if (htc->pipeline.b) {
-		l = Tlen(htc->pipeline);
+	if (htc->pipeline_b) {
+		l = htc->pipeline_e - htc->pipeline_b;
+		assert(l > 0);
 		if (l > len)
 			l = len;
-		memcpy(p, htc->pipeline.b, l);
+		memcpy(p, htc->pipeline_b, l);
 		p += l;
 		len -= l;
-		htc->pipeline.b += l;
-		if (htc->pipeline.b == htc->pipeline.e)
-			htc->pipeline.b = htc->pipeline.e = NULL;
+		htc->pipeline_b += l;
+		if (htc->pipeline_b == htc->pipeline_e)
+			htc->pipeline_b = htc->pipeline_e = NULL;
 	}
 	if (len > 0) {
 		i = read(htc->fd, p, len);
diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c
index 9d43be0..2e2d57d 100644
--- a/bin/varnishd/cache/cache_pipe.c
+++ b/bin/varnishd/cache/cache_pipe.c
@@ -126,9 +126,9 @@ PipeRequest(struct req *req, struct busyobj *bo)
 	WRW_Reserve(wrk, &vc->fd, bo->vsl, req->t_req);
 	hdrbytes = HTTP1_Write(wrk, bo->bereq, HTTP1_Req);
 
-	if (req->htc->pipeline.b != NULL)
-		(void)WRW_Write(wrk, req->htc->pipeline.b,
-		    Tlen(req->htc->pipeline));
+	if (req->htc->pipeline_b != NULL)
+		(void)WRW_Write(wrk, req->htc->pipeline_b,
+		    req->htc->pipeline_e - req->htc->pipeline_b);
 
 	i = WRW_FlushRelease(wrk, &acct_pipe.bereq);
 	if (acct_pipe.bereq > hdrbytes) {



More information about the varnish-commit mailing list