[master] 4e5828d move vbc from bo to bo->htc

Poul-Henning Kamp phk at FreeBSD.org
Mon Oct 13 11:37:33 CEST 2014


commit 4e5828d80b63df8c6d91a37d8b8a35883c014d77
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Oct 13 09:37:20 2014 +0000

    move vbc from bo to bo->htc

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index f08631f..0748d66 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -254,6 +254,7 @@ struct http_conn {
 	ssize_t			content_length;
 	enum body_status	body_status;
 	struct vfp_ctx		vfc[1];
+	struct vbc		*vbc;
 };
 
 /*--------------------------------------------------------------------*/
@@ -489,7 +490,6 @@ struct busyobj {
 
 	struct ws		ws[1];
 	char			*ws_bo;
-	struct vbc		*vbc;
 	struct http		*bereq0;
 	struct http		*bereq;
 	struct http		*beresp;
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index a42f731..d073e60 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -353,20 +353,20 @@ vbe_dir_getfd(const struct director *d, struct busyobj *bo)
 	CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
 	CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
 
-	AZ(bo->htc);
-	bo->htc = WS_Alloc(bo->ws, sizeof *bo->htc);
-	memset(bo->htc, 0, sizeof *bo->htc);
-	bo->htc->magic = HTTP_CONN_MAGIC;
-
 	vc = vbe_GetVbe(bo, vs);
-	if (vc != NULL) {
-		FIND_TMO(first_byte_timeout,
-		    vc->first_byte_timeout, bo, vs->vrt);
-		FIND_TMO(between_bytes_timeout,
-		    vc->between_bytes_timeout, bo, vs->vrt);
-	}
-	if (vc == NULL)
+	if (vc == NULL) {
 		VSLb(bo->vsl, SLT_FetchError, "no backend connection");
+		return (NULL);
+	}
+
+	if (bo->htc == NULL)
+		bo->htc = WS_Alloc(bo->ws, sizeof *bo->htc);
+	memset(bo->htc, 0, sizeof *bo->htc);
+	bo->htc->magic = HTTP_CONN_MAGIC;
+	bo->htc->vbc = vc;
+	bo->htc->fd = vc->fd;
+	FIND_TMO(first_byte_timeout, vc->first_byte_timeout, bo, vs->vrt);
+	FIND_TMO(between_bytes_timeout, vc->between_bytes_timeout, bo, vs->vrt);
 	return (vc);
 }
 
@@ -388,15 +388,15 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
     struct busyobj *bo)
 {
 	int i;
+	struct vbc *vbc;
 
 	CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 
-	bo->vbc = vbe_dir_getfd(d, bo);
-	if (bo->vbc == NULL) {
+	vbc = vbe_dir_getfd(d, bo);
+	if (vbc == NULL) {
 		VSLb(bo->vsl, SLT_FetchError, "no backend connection");
-		bo->htc = NULL;
 		return (-1);
 	}
 
@@ -407,11 +407,11 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
 	 * Do a single retry in that case.
 	 */
 	if (i == 1) {
-		AZ(bo->vbc);
+		AZ(bo->htc);
 		VSC_C_main->backend_retry++;
 		bo->doclose = SC_NULL;
-		bo->vbc = vbe_dir_getfd(d, bo);
-		if (bo->vbc == NULL) {
+		bo->htc->vbc = vbe_dir_getfd(d, bo);
+		if (bo->htc->vbc == NULL) {
 			VSLb(bo->vsl, SLT_FetchError, "no backend connection");
 			bo->htc = NULL;
 			return (-1);
@@ -420,9 +420,9 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
 	}
 	if (i != 0) {
 		bo->doclose = SC_NULL;
-		AZ(bo->vbc);
+		AZ(bo->htc);
 	} else {
-		AN(bo->vbc);
+		AN(bo->htc->vbc);
 	}
 	return (i);
 }
@@ -451,26 +451,26 @@ vbe_dir_finish(const struct director *d, struct worker *wrk,
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 
 	CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC);
-	bo->htc = NULL;
-	if (bo->vbc == NULL)
+	if (bo->htc->vbc == NULL)
 		return;
-	bp = bo->vbc->backend;
+	bp = bo->htc->vbc->backend;
 	if (bo->doclose != SC_NULL) {
-		VSLb(bo->vsl, SLT_BackendClose, "%d %s", bo->vbc->fd,
+		VSLb(bo->vsl, SLT_BackendClose, "%d %s", bo->htc->vbc->fd,
 		    bp->display_name);
-		VTCP_close(&bo->vbc->fd);
+		VTCP_close(&bo->htc->vbc->fd);
 		VBE_DropRefConn(bp, &bo->acct);
-		bo->vbc->backend = NULL;
-		VBE_ReleaseConn(bo->vbc);
+		bo->htc->vbc->backend = NULL;
+		VBE_ReleaseConn(bo->htc->vbc);
 	} else {
-		VSLb(bo->vsl, SLT_BackendReuse, "%d %s", bo->vbc->fd,
+		VSLb(bo->vsl, SLT_BackendReuse, "%d %s", bo->htc->vbc->fd,
 		    bp->display_name);
 		Lck_Lock(&bp->mtx);
 		VSC_C_main->backend_recycle++;
-		VTAILQ_INSERT_HEAD(&bp->connlist, bo->vbc, list);
+		VTAILQ_INSERT_HEAD(&bp->connlist, bo->htc->vbc, list);
 		VBE_DropRefLocked(bp, &bo->acct);
 	}
-	bo->vbc = NULL;
+	bo->htc->vbc = NULL;
+	bo->htc = NULL;
 }
 
 static struct suckaddr * __match_proto__(vdi_suckaddr_f)
@@ -481,8 +481,8 @@ vbe_dir_suckaddr(const struct director *d, struct worker *wrk,
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 
-	if (bo->vbc != NULL)
-		return(bo->vbc->addr);
+	if (bo->htc->vbc != NULL)
+		return(bo->htc->vbc->addr);
 	return (NULL);
 }
 
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index e605ef4..ad31e11 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -200,7 +200,7 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo)
 
 	VSL_End(bo->vsl);
 
-	AZ(bo->vbc);
+	AZ(bo->htc);
 
 	if (bo->fetch_objcore != NULL) {
 		AN(wrk);
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index ab95e03..5b977be 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -338,8 +338,8 @@ pan_busyobj(const struct busyobj *bo)
 		VSB_printf(pan_vsp, "\n");
 	}
 	VSB_printf(pan_vsp, "    },\n");
-	if (VALID_OBJ(bo->vbc, BACKEND_MAGIC))
-		pan_vbc(bo->vbc);
+	if (VALID_OBJ(bo->htc->vbc, BACKEND_MAGIC))
+		pan_vbc(bo->htc->vbc);
 	if (bo->bereq->ws != NULL)
 		pan_http("bereq", bo->bereq, 4);
 	if (bo->beresp->ws != NULL)
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 64bb63a..3289acd 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -88,12 +88,12 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC);
-	CHECK_OBJ_NOTNULL(bo->vbc, VBC_MAGIC);
+	CHECK_OBJ_NOTNULL(bo->htc->vbc, VBC_MAGIC);
 	CHECK_OBJ_ORNULL(bo->req, REQ_MAGIC);
 
 	htc = bo->htc;
 	hp = bo->bereq;
-	vc = bo->vbc;
+	vc = htc->vbc;
 	if (vc->recycled)
 		retry = 1;
 
diff --git a/bin/varnishd/http1/cache_http1_pipe.c b/bin/varnishd/http1/cache_http1_pipe.c
index 5620d0d..84d91c4 100644
--- a/bin/varnishd/http1/cache_http1_pipe.c
+++ b/bin/varnishd/http1/cache_http1_pipe.c
@@ -120,12 +120,13 @@ V1P_Process(struct req *req, struct busyobj *bo)
 		SES_Close(req->sp, SC_OVERLOAD);
 		return;
 	}
-	bo->vbc = vc;		/* For panic dumping */
+	CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC);
+	assert(bo->htc->fd >= 0);
 	bo->wrk = req->wrk;
 	bo->director_state = DIR_S_BODY;
-	(void)VTCP_blocking(vc->fd);
+	(void)VTCP_blocking(bo->htc->fd);
 
-	WRW_Reserve(wrk, &vc->fd, bo->vsl, req->t_req);
+	WRW_Reserve(wrk, &bo->htc->fd, bo->vsl, req->t_req);
 	hdrbytes = HTTP1_Write(wrk, bo->bereq, HTTP1_Req);
 
 	if (req->htc->pipeline_b != NULL)
@@ -142,7 +143,7 @@ V1P_Process(struct req *req, struct busyobj *bo)
 
 	if (i == 0) {
 		memset(fds, 0, sizeof fds);
-		fds[0].fd = vc->fd;
+		fds[0].fd = bo->htc->fd;
 		fds[0].events = POLLIN | POLLERR;
 		fds[1].fd = req->sp->fd;
 		fds[1].events = POLLIN | POLLERR;
@@ -155,20 +156,20 @@ V1P_Process(struct req *req, struct busyobj *bo)
 			if (i < 1)
 				break;
 			if (fds[0].revents &&
-			    rdf(vc->fd, req->sp->fd, &acct_pipe.out)) {
+			    rdf(bo->htc->fd, req->sp->fd, &acct_pipe.out)) {
 				if (fds[1].fd == -1)
 					break;
-				(void)shutdown(vc->fd, SHUT_RD);
+				(void)shutdown(bo->htc->fd, SHUT_RD);
 				(void)shutdown(req->sp->fd, SHUT_WR);
 				fds[0].events = 0;
 				fds[0].fd = -1;
 			}
 			if (fds[1].revents &&
-			    rdf(req->sp->fd, vc->fd, &acct_pipe.in)) {
+			    rdf(req->sp->fd, bo->htc->fd, &acct_pipe.in)) {
 				if (fds[0].fd == -1)
 					break;
 				(void)shutdown(req->sp->fd, SHUT_RD);
-				(void)shutdown(vc->fd, SHUT_WR);
+				(void)shutdown(bo->htc->fd, SHUT_WR);
 				fds[1].events = 0;
 				fds[1].fd = -1;
 			}



More information about the varnish-commit mailing list