[master] ac4e79e Move some args from busyobj to vfp_ctx

Poul-Henning Kamp phk at FreeBSD.org
Tue Jul 22 17:13:25 CEST 2014


commit ac4e79e5ec3d037bfe0c009dd53d266368d1108d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Jul 22 15:09:03 2014 +0000

    Move some args from busyobj to vfp_ctx

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 53b7c78..8a3d0ae 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -897,7 +897,7 @@ void VBF_Fetch(struct worker *wrk, struct req *req,
     struct objcore *oc, struct object *oldobj, enum vbf_fetch_mode_e);
 
 /* cache_fetch_proc.c */
-struct storage *VFP_GetStorage(struct busyobj *, ssize_t sz);
+struct storage *VFP_GetStorage(struct vfp_ctx *, ssize_t sz);
 void VFP_Init(void);
 void VFP_Fetch_Body(struct busyobj *bo);
 
@@ -1211,7 +1211,7 @@ void RFC2616_Weaken_Etag(struct http *hp);
 /* stevedore.c */
 struct object *STV_NewObject(struct busyobj *,
     const char *hint, unsigned len, uint16_t nhttp);
-struct storage *STV_alloc(struct busyobj *, size_t size);
+struct storage *STV_alloc(const struct vfp_ctx *, size_t size);
 void STV_trim(struct storage *st, size_t size, int move_ok);
 void STV_free(struct storage *st);
 void STV_open(void);
diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index 786d638..c4bcef9 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -83,7 +83,7 @@ vfp_vep_callback(struct busyobj *bo, void *priv, ssize_t l, enum vgz_flag flg)
 
 	VGZ_Ibuf(vef->vgz, vef->ibuf_o, l);
 	do {
-		st = VFP_GetStorage(bo, 0);
+		st = VFP_GetStorage(bo->vfc, 0);
 		if (st == NULL) {
 			vef->error = ENOMEM;
 			vef->tot += l;
@@ -118,7 +118,7 @@ vfp_esi_end(struct vfp_ctx *vc, struct vef_priv *vef,
 			l = VSB_len(vsb);
 			assert(l > 0);
 			/* XXX: This is a huge waste of storage... */
-			vc->bo->fetch_obj->esidata = STV_alloc(vc->bo, l);
+			vc->bo->fetch_obj->esidata = STV_alloc(vc, l);
 			if (vc->bo->fetch_obj->esidata != NULL) {
 				memcpy(vc->bo->fetch_obj->esidata->ptr,
 				    VSB_data(vsb), l);
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 97718bf..ad0c168 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -582,7 +582,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 
 	if (bo->ims_obj->esidata != NULL) {
 		sl = bo->ims_obj->esidata->len;
-		obj->esidata = STV_alloc(bo, sl);
+		obj->esidata = STV_alloc(bo->vfc, sl);
 		if (obj->esidata == NULL || obj->esidata->space < sl) {
 			VSLb(bo->vsl, SLT_Error,
 			    "No space for %zd bytes of ESI data", sl);
@@ -611,7 +611,8 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 		ois = ObjIter(oi, &sp, &sl);
 		while (sl > 0) {
 			if (st == NULL)
-				st = VFP_GetStorage(bo, bo->ims_obj->len - al);
+				st = VFP_GetStorage(bo->vfc,
+				    bo->ims_obj->len - al);
 			if (st == NULL)
 				break;
 			tl = sl;
@@ -702,12 +703,17 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
 
 	assert(wrk->handling == VCL_RET_DELIVER);
 
+	VFP_Setup(bo->vfc);
+	bo->vfc->bo = bo;
+	bo->vfc->http = bo->beresp;
+	bo->vfc->vsl = bo->vsl;
+
 	if (vbf_beresp2obj(bo))
 		return (F_STP_FAIL);
 
 	l = VSB_len(bo->synth_body);
 	if (l > 0) {
-		st = VFP_GetStorage(bo, l);
+		st = VFP_GetStorage(bo->vfc, l);
 		if (st != NULL) {
 			if (st->space < l) {
 				VSLb(bo->vsl, SLT_Error,
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index e72d74f..87d3b6d 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -74,33 +74,34 @@ VFP_Error(struct vfp_ctx *vc, const char *fmt, ...)
  */
 
 struct storage *
-VFP_GetStorage(struct busyobj *bo, ssize_t sz)
+VFP_GetStorage(struct vfp_ctx *vc, ssize_t sz)
 {
 	ssize_t l;
 	struct storage *st;
 	struct object *obj;
 
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
-	obj = bo->fetch_obj;
+	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
+	CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC);
+	obj = vc->bo->fetch_obj;
 	CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
 	st = VTAILQ_LAST(&obj->body->list, storagehead);
 	if (st != NULL && st->len < st->space)
 		return (st);
 
-	AN(bo->stats);
+	AN(vc->bo->stats);
 	l = fetchfrag;
 	if (l == 0)
 		l = sz;
 	if (l == 0)
 		l = cache_param->fetch_chunksize;
-	st = STV_alloc(bo, l);
+	st = STV_alloc(vc, l);
 	if (st == NULL) {
-		(void)VFP_Error(bo->vfc, "Could not get storage");
+		(void)VFP_Error(vc, "Could not get storage");
 	} else {
 		AZ(st->len);
-		Lck_Lock(&bo->mtx);
+		Lck_Lock(&vc->bo->mtx);
 		VTAILQ_INSERT_TAIL(&obj->body->list, st, list);
-		Lck_Unlock(&bo->mtx);
+		Lck_Unlock(&vc->bo->mtx);
 	}
 	return (st);
 }
@@ -222,7 +223,7 @@ VFP_Fetch_Body(struct busyobj *bo)
 		}
 		AZ(bo->vfc->failed);
 		if (st == NULL) {
-			st = VFP_GetStorage(bo, est);
+			st = VFP_GetStorage(bo->vfc, est);
 			est = 0;
 		}
 		if (st == NULL) {
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 8542b31..c982235 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -606,7 +606,6 @@ cnt_pipe(struct worker *wrk, struct req *req)
 	http_FilterReq(bo->bereq, req->http, 0);	// XXX: 0 ?
 	http_PrintfHeader(bo->bereq, "X-Varnish: %u", VXID(req->vsl->wid));
 	http_SetHeader(bo->bereq, "Connection: close");
-	
 
 	VCL_pipe_method(req->vcl, wrk, req, bo, req->http->ws);
 
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index 44ed2b6..ad2106b 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -192,7 +192,7 @@ stv_alloc(struct stevedore *stv, size_t size)
 /*-------------------------------------------------------------------*/
 
 static struct storage *
-stv_alloc_obj(struct busyobj *bo, size_t size)
+stv_alloc_obj(const struct vfp_ctx *vc, size_t size)
 {
 	struct storage *st = NULL;
 	struct stevedore *stv;
@@ -203,9 +203,10 @@ stv_alloc_obj(struct busyobj *bo, size_t size)
 	 * Always use the stevedore which allocated the object in order to
 	 * keep an object inside the same stevedore.
 	 */
-	AN(bo->stats);
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
-	obj = bo->fetch_obj;
+	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
+	CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC);
+	AN(vc->bo->stats);
+	obj = vc->bo->fetch_obj;
 	CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
 	stv = obj->body->stevedore;
 	CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
@@ -224,7 +225,7 @@ stv_alloc_obj(struct busyobj *bo, size_t size)
 
 		/* no luck; try to free some space and keep trying */
 		if (fail < cache_param->nuke_limit &&
-		    EXP_NukeOne(bo, stv->lru) == -1)
+		    EXP_NukeOne(vc->bo, stv->lru) == -1)
 			break;
 	}
 	CHECK_OBJ_ORNULL(st, STORAGE_MAGIC);
@@ -410,10 +411,10 @@ STV_Freestore(struct object *o)
 /*-------------------------------------------------------------------*/
 
 struct storage *
-STV_alloc(struct busyobj *bo, size_t size)
+STV_alloc(const struct vfp_ctx *vc, size_t size)
 {
 
-	return (stv_alloc_obj(bo, size));
+	return (stv_alloc_obj(vc, size));
 }
 
 struct storage *



More information about the varnish-commit mailing list