[master] eb6fa2f Move vfp from worker to busyobj

Poul-Henning Kamp phk at varnish-cache.org
Tue Nov 29 18:30:54 CET 2011


commit eb6fa2f150979d12ede60d2075f76102f45eb1ee
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Nov 29 17:30:40 2011 +0000

    Move vfp from worker to busyobj

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 7ad7fbd..21382d7 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -334,7 +334,6 @@ struct worker {
 	struct vbc		*vbc;
 	struct object		*fetch_obj;
 	enum body_status	body_status;
-	struct vfp		*vfp;
 	struct vgz		*vgz_rx;
 	struct vef_priv		*vef_priv;
 	unsigned		fetch_failed;
@@ -485,7 +484,16 @@ oc_getlru(const struct objcore *oc)
 	return (oc->methods->getlru(oc));
 }
 
-/* Busy Object structure ---------------------------------------------*/
+/* Busy Object structure ---------------------------------------------
+ *
+ * The busyobj structure captures the aspects of an object related to,
+ * and while it is being fetched from the backend.
+ *
+ * One of these aspects will be how much has been fetched, which
+ * streaming delivery will make use of.
+ *
+ * XXX: many fields from worker needs to move here.
+ */
 
 struct busyobj {
 	unsigned		magic;
@@ -493,6 +501,8 @@ struct busyobj {
 	uint8_t			*vary;
 	unsigned		is_gzip;
 	unsigned		is_gunzip;
+
+	struct vfp		*vfp;
 };
 
 /* Object structure --------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 85224b6..27209de 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -706,7 +706,6 @@ cnt_fetchbody(struct sess *sp)
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	wrk = sp->wrk;
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-
 	CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
 
 	assert(sp->handling == VCL_RET_HIT_FOR_PASS ||
@@ -739,8 +738,6 @@ cnt_fetchbody(struct sess *sp)
 	 *
 	 */
 
-	AZ(wrk->vfp);
-
 	/* We do nothing unless the param is set */
 	if (!cache_param->http_gzip_support)
 		wrk->do_gzip = wrk->do_gunzip = 0;
@@ -776,13 +773,13 @@ cnt_fetchbody(struct sess *sp)
 
 	/* ESI takes precedence and handles gzip/gunzip itself */
 	if (wrk->do_esi)
-		wrk->vfp = &vfp_esi;
+		wrk->busyobj->vfp = &vfp_esi;
 	else if (wrk->do_gunzip)
-		wrk->vfp = &vfp_gunzip;
+		wrk->busyobj->vfp = &vfp_gunzip;
 	else if (wrk->do_gzip)
-		wrk->vfp = &vfp_gzip;
+		wrk->busyobj->vfp = &vfp_gzip;
 	else if (wrk->busyobj->is_gzip)
-		wrk->vfp = &vfp_testgzip;
+		wrk->busyobj->vfp = &vfp_testgzip;
 
 	if (wrk->do_esi || sp->esi_level > 0)
 		wrk->do_stream = 0;
@@ -890,7 +887,7 @@ cnt_fetchbody(struct sess *sp)
 
 	http_Setup(wrk->bereq, NULL);
 	http_Setup(wrk->beresp, NULL);
-	wrk->vfp = NULL;
+	wrk->busyobj->vfp = NULL;
 	assert(WRW_IsReleased(wrk));
 	AZ(wrk->vbc);
 	AN(sp->director);
@@ -960,7 +957,7 @@ cnt_streambody(struct sess *sp)
 
 	http_Setup(wrk->bereq, NULL);
 	http_Setup(wrk->beresp, NULL);
-	wrk->vfp = NULL;
+	wrk->busyobj->vfp = NULL;
 	AZ(wrk->vbc);
 	AN(sp->director);
 
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 66241bc..9413300 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -236,7 +236,7 @@ fetch_straight(struct worker *w, struct http_conn *htc, ssize_t cl)
 	} else if (cl == 0)
 		return (0);
 
-	i = w->vfp->bytes(w, htc, cl);
+	i = w->busyobj->vfp->bytes(w, htc, cl);
 	if (i <= 0)
 		return (FetchError(w, "straight insufficient bytes"));
 	return (0);
@@ -293,7 +293,7 @@ fetch_chunked(struct worker *w, struct http_conn *htc)
 		if (cl < 0)
 			return (FetchError(w,"chunked header number syntax"));
 
-		if (cl > 0 && w->vfp->bytes(w, htc, cl) <= 0)
+		if (cl > 0 && w->busyobj->vfp->bytes(w, htc, cl) <= 0)
 			return (-1);
 
 		i = HTC_Read(w, htc, buf, 1);
@@ -315,7 +315,7 @@ fetch_eof(struct worker *w, struct http_conn *htc)
 	int i;
 
 	assert(w->body_status == BS_EOF);
-	i = w->vfp->bytes(w, htc, SSIZE_MAX);
+	i = w->busyobj->vfp->bytes(w, htc, SSIZE_MAX);
 	if (i < 0)
 		return (-1);
 	return (0);
@@ -494,8 +494,8 @@ FetchBody(struct worker *w, struct object *obj)
 	CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
 	CHECK_OBJ_NOTNULL(obj->http, HTTP_MAGIC);
 
-	if (w->vfp == NULL)
-		w->vfp = &vfp_nop;
+	if (w->busyobj->vfp == NULL)
+		w->busyobj->vfp = &vfp_nop;
 
 	AssertObjCorePassOrBusy(obj->objcore);
 
@@ -518,24 +518,24 @@ FetchBody(struct worker *w, struct object *obj)
 		break;
 	case BS_LENGTH:
 		cl = fetch_number( w->h_content_length, 10);
-		w->vfp->begin(w, cl > 0 ? cl : 0);
+		w->busyobj->vfp->begin(w, cl > 0 ? cl : 0);
 		cls = fetch_straight(w, w->htc, cl);
 		mklen = 1;
-		if (w->vfp->end(w))
+		if (w->busyobj->vfp->end(w))
 			cls = -1;
 		break;
 	case BS_CHUNKED:
-		w->vfp->begin(w, cl);
+		w->busyobj->vfp->begin(w, cl);
 		cls = fetch_chunked(w, w->htc);
 		mklen = 1;
-		if (w->vfp->end(w))
+		if (w->busyobj->vfp->end(w))
 			cls = -1;
 		break;
 	case BS_EOF:
-		w->vfp->begin(w, cl);
+		w->busyobj->vfp->begin(w, cl);
 		cls = fetch_eof(w, w->htc);
 		mklen = 1;
-		if (w->vfp->end(w))
+		if (w->busyobj->vfp->end(w))
 			cls = -1;
 		break;
 	case BS_ERROR:



More information about the varnish-commit mailing list