[master] 0ff51bd Trying to clean up various function arguments by moving towards struct worker for "usual stuff" like vsl, stats etc.

Poul-Henning Kamp phk at FreeBSD.org
Tue Sep 16 10:41:05 CEST 2014


commit 0ff51bd69a8b4ac2803b3071b648a962ab02b4b7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Sep 16 08:40:25 2014 +0000

    Trying to clean up various function arguments by moving towards
    struct worker for "usual stuff" like vsl, stats etc.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index d68e05f..df62953 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -218,15 +218,14 @@ struct vfp_ctx {
 	unsigned		magic;
 #define VFP_CTX_MAGIC		0x61d9d3e5
 	struct busyobj		*bo;
+	struct worker		*wrk;
 	struct objcore		*oc;
-	struct dstat		*stats;
 
 	int			failed;
 
 	struct vfp_entry_s	vfp;
 	struct vfp_entry	*vfp_nxt;
 
-	struct vsl_log		*vsl;
 	struct http		*http;
 	struct http		*esi_req;
 };
@@ -513,7 +512,6 @@ struct busyobj {
 	struct VCL_conf		*vcl;
 
 	struct vsl_log		vsl[1];
-	struct dstat		*stats;
 
 	struct vsb		*synth_body;
 };
@@ -819,7 +817,7 @@ void EXP_Init(void);
 void EXP_Rearm(struct objcore *, double now, double ttl, double grace,
     double keep);
 void EXP_Touch(struct objcore *oc, double now);
-int EXP_NukeOne(struct vsl_log *vsl, struct dstat *ds, struct lru *lru);
+int EXP_NukeOne(struct worker *wrk, struct lru *lru);
 
 /* cache_fetch.c */
 enum vbf_fetch_mode_e {
@@ -983,8 +981,7 @@ enum objiter_status {
 void *ObjIterBegin(struct objcore *, struct worker *);
 enum objiter_status ObjIter(struct objcore *, void *, void **, ssize_t *);
 void ObjIterEnd(struct objcore *, void **);
-int ObjGetSpace(struct objcore *, struct vsl_log *vsl,
-    struct dstat *, ssize_t *sz, uint8_t **ptr);
+int ObjGetSpace(struct objcore *, struct worker *, ssize_t *sz, uint8_t **ptr);
 void ObjExtend(struct objcore *, struct dstat *, ssize_t l);
 void ObjTrimStore(struct objcore *, struct dstat *);
 unsigned ObjGetXID(struct objcore *, struct dstat *);
@@ -1166,7 +1163,7 @@ void RFC2616_Weaken_Etag(struct http *hp);
 void RFC2616_Vary_AE(struct http *hp);
 
 /* stevedore.c */
-int STV_NewObject(struct objcore *, struct vsl_log *, struct dstat *,
+int STV_NewObject(struct objcore *, struct worker *,
     const char *hint, unsigned len);
 struct storage *STV_alloc(struct stevedore *, size_t size);
 void STV_trim(struct storage *st, size_t size, int move_ok);
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index dd7834f..53f5abe 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -224,7 +224,7 @@ VBO_extend(struct busyobj *bo, ssize_t l)
 		return;
 	assert(l > 0);
 	Lck_Lock(&bo->mtx);
-	ObjExtend(bo->vfc->oc, bo->stats, l);
+	ObjExtend(bo->vfc->oc, bo->wrk->stats, l);
 	AZ(pthread_cond_broadcast(&bo->cond));
 	Lck_Unlock(&bo->mtx);
 }
diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index ce76cec..8a73566 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -150,7 +150,7 @@ vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
 	ALLOC_OBJ(vef, VEF_MAGIC);
 	if (vef == NULL)
 		return (VFP_ERROR);
-	vef->vgz = VGZ_NewGzip(vc->vsl, "G F E");
+	vef->vgz = VGZ_NewGzip(vc->wrk->vsl, "G F E");
 	vef->vep = VEP_Init(vc, vc->esi_req, vfp_vep_callback, vef);
 	vef->ibuf_sz = cache_param->gzip_buffer;
 	vef->ibuf = calloc(1L, vef->ibuf_sz);
diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c
index 1860b8f..ab2a4f5 100644
--- a/bin/varnishd/cache/cache_esi_parse.c
+++ b/bin/varnishd/cache/cache_esi_parse.c
@@ -196,7 +196,7 @@ vep_error(const struct vep_state *vep, const char *p)
 
 	VSC_C_main->esi_errors++;
 	l = (intmax_t)(vep->ver_p - vep->hack_p);
-	VSLb(vep->vc->vsl, SLT_ESI_xmlerror, "ERR at %jd %s", l, p);
+	VSLb(vep->vc->wrk->vsl, SLT_ESI_xmlerror, "ERR at %jd %s", l, p);
 
 }
 
@@ -211,7 +211,7 @@ vep_warn(const struct vep_state *vep, const char *p)
 
 	VSC_C_main->esi_warnings++;
 	l = (intmax_t)(vep->ver_p - vep->hack_p);
-	VSLb(vep->vc->vsl, SLT_ESI_xmlerror, "WARN at %jd %s", l, p);
+	VSLb(vep->vc->wrk->vsl, SLT_ESI_xmlerror, "WARN at %jd %s", l, p);
 
 }
 
@@ -634,14 +634,14 @@ VEP_Parse(struct vep_state *vep, const char *p, size_t l)
 				p++;
 				vep->state = VEP_STARTTAG;
 			} else if (p < e && *p == '\xeb') {
-				VSLb(vep->vc->vsl, SLT_ESI_xmlerror,
+				VSLb(vep->vc->wrk->vsl, SLT_ESI_xmlerror,
 				    "No ESI processing, "
 				    "first char not '<' but BOM."
 				    " (See feature esi_remove_bom)"
 				);
 				vep->state = VEP_NOTXML;
 			} else if (p < e) {
-				VSLb(vep->vc->vsl, SLT_ESI_xmlerror,
+				VSLb(vep->vc->wrk->vsl, SLT_ESI_xmlerror,
 				    "No ESI processing, "
 				    "first char not '<'."
 				    " (See feature esi_disable_xml_check)"
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index 0b9772e..6753669 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -286,20 +286,19 @@ EXP_Rearm(struct objcore *oc, double now, double ttl, double grace, double keep)
  */
 
 int
-EXP_NukeOne(struct vsl_log *vsl, struct dstat *ds, struct lru *lru)
+EXP_NukeOne(struct worker *wrk, struct lru *lru)
 {
 	struct objcore *oc, *oc2;
 	struct objhead *oh;
 
-	AN(vsl);
-	AN(ds);
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
 	/* Find the first currently unused object on the LRU.  */
 	Lck_Lock(&lru->mtx);
 	VTAILQ_FOREACH_SAFE(oc, &lru->lru_head, lru_list, oc2) {
 		CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 
-		VSLb(vsl, SLT_ExpKill, "LRU_Cand p=%p f=0x%x r=%d",
+		VSLb(wrk->vsl, SLT_ExpKill, "LRU_Cand p=%p f=0x%x r=%d",
 		    oc, oc->flags, oc->refcnt);
 
 		AZ(oc->exp_flags & OC_EF_OFFLRU);
@@ -331,17 +330,17 @@ EXP_NukeOne(struct vsl_log *vsl, struct dstat *ds, struct lru *lru)
 	Lck_Unlock(&lru->mtx);
 
 	if (oc == NULL) {
-		VSLb(vsl, SLT_ExpKill, "LRU_Fail");
+		VSLb(wrk->vsl, SLT_ExpKill, "LRU_Fail");
 		return (-1);
 	}
 
 	/* XXX: We could grab and return one storage segment to our caller */
-	ObjSlim(oc, ds);
+	ObjSlim(oc, wrk->stats);
 
 	exp_mail_it(oc);
 
-	VSLb(vsl, SLT_ExpKill, "LRU x=%u", ObjGetXID(oc, ds));
-	(void)HSH_DerefObjCore(ds, &oc);
+	VSLb(wrk->vsl, SLT_ExpKill, "LRU x=%u", ObjGetXID(oc, wrk->stats));
+	(void)HSH_DerefObjCore(wrk->stats, &oc);
 	return (1);
 }
 
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 99654ae..e6bc239 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -66,8 +66,7 @@ vbf_allocobj(struct busyobj *bo, unsigned l)
 
 	bo->storage_hint = NULL;
 
-	if (STV_NewObject(bo->fetch_objcore, bo->vsl, bo->stats,
-	    storage_hint, l))
+	if (STV_NewObject(bo->fetch_objcore, bo->wrk, storage_hint, l))
 		return (1);
 
 	if (storage_hint != NULL && !strcmp(storage_hint, TRANSIENT_STORAGE))
@@ -82,7 +81,7 @@ vbf_allocobj(struct busyobj *bo, unsigned l)
 		oc->exp.ttl = cache_param->shortlived;
 	oc->exp.grace = 0.0;
 	oc->exp.keep = 0.0;
-	return (STV_NewObject(bo->fetch_objcore, bo->vsl, bo->stats,
+	return (STV_NewObject(bo->fetch_objcore, bo->wrk,
 	    TRANSIENT_STORAGE, l));
 }
 
@@ -191,11 +190,12 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo)
 	}
 
 	if (bo->ims_oc != NULL) {
-		q = HTTP_GetHdrPack(bo->ims_oc, bo->stats, H_Last_Modified);
+		q = HTTP_GetHdrPack(bo->ims_oc, bo->wrk->stats,
+		    H_Last_Modified);
 		if (q != NULL)
 			http_PrintfHeader(bo->bereq0,
 			    "If-Modified-Since: %s", q);
-		q = HTTP_GetHdrPack(bo->ims_oc, bo->stats, H_ETag);
+		q = HTTP_GetHdrPack(bo->ims_oc, bo->wrk->stats, H_ETag);
 		if (q != NULL)
 			http_PrintfHeader(bo->bereq0,
 			    "If-None-Match: %s", q);
@@ -381,7 +381,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 	AZ(bo->do_esi);
 
 	if (bo->ims_oc != NULL && http_IsStatus(bo->beresp, 304)) {
-		if (ObjCheckFlag(bo->ims_oc, bo->stats, OF_CHGGZIP)) {
+		if (ObjCheckFlag(bo->ims_oc, bo->wrk->stats, OF_CHGGZIP)) {
 			/*
 			 * If we changed the gzip status of the object
 			 * the stored Content_Encoding controls we
@@ -390,7 +390,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 			http_Unset(bo->beresp, H_Content_Encoding);
 			RFC2616_Weaken_Etag(bo->beresp);
 		}
-		HTTP_Merge(bo->ims_oc, bo->stats, bo->beresp);
+		HTTP_Merge(bo->ims_oc, bo->wrk->stats, bo->beresp);
 		assert(http_IsStatus(bo->beresp, 200));
 		do_ims = 1;
 	} else
@@ -399,10 +399,9 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 	VFP_Setup(bo->vfc);
 	bo->vfc->bo = bo;
 	bo->vfc->oc = bo->fetch_objcore;
-	bo->vfc->stats = bo->stats;
+	bo->vfc->wrk = bo->wrk;
 	bo->vfc->http = bo->beresp;
 	bo->vfc->esi_req = bo->bereq;
-	bo->vfc->vsl = bo->vsl;
 
 	VCL_backend_response_method(bo->vcl, wrk, NULL, bo, bo->beresp->ws);
 
@@ -463,7 +462,7 @@ vbf_fetch_body_helper(struct busyobj *bo)
 			 * objects to be created.
 			 */
 			AN(vfc->oc->flags & OC_F_PASS);
-			VSLb(vfc->vsl, SLT_FetchError,
+			VSLb(vfc->wrk->vsl, SLT_FetchError,
 			    "Pass delivery abandoned");
 			vfps = VFP_END;
 			bo->doclose = SC_RX_BODY;
@@ -498,7 +497,7 @@ vbf_fetch_body_helper(struct busyobj *bo)
 	VFP_Close(vfc);
 
 	if (!bo->do_stream)
-		ObjTrimStore(vfc->oc, bo->stats);
+		ObjTrimStore(vfc->oc, bo->wrk->stats);
 }
 
 /*--------------------------------------------------------------------
@@ -627,7 +626,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 	if (bo->vfc->failed && !bo->do_stream) {
 		assert(bo->state < BOS_STREAM);
 		if (bo->fetch_objcore != NULL)
-			ObjFreeObj(bo->fetch_objcore, bo->stats);
+			ObjFreeObj(bo->fetch_objcore, bo->wrk->stats);
 		return (F_STP_ERROR);
 	}
 
@@ -673,7 +672,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 
 	AZ(vbf_beresp2obj(bo));
 
-	if (ObjGetattr(bo->ims_oc, bo->stats, OA_ESIDATA, NULL) != NULL)
+	if (ObjGetattr(bo->ims_oc, bo->wrk->stats, OA_ESIDATA, NULL) != NULL)
 		AZ(ObjCopyAttr(bo->vfc, bo->ims_oc, OA_ESIDATA));
 
 	AZ(ObjCopyAttr(bo->vfc, bo->ims_oc, OA_FLAGS));
@@ -685,7 +684,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 	}
 
 	al = 0;
-	ol = ObjGetLen(bo->ims_oc, bo->stats);
+	ol = ObjGetLen(bo->ims_oc, bo->wrk->stats);
 	oi = ObjIterBegin(bo->ims_oc, wrk);
 	do {
 		ois = ObjIter(bo->ims_oc, oi, &sp, &sl);
@@ -710,7 +709,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 		HSH_Unbusy(wrk->stats, bo->fetch_objcore);
 
 	assert(al == ol);
-	assert(ObjGetLen(bo->fetch_objcore, bo->stats) == al);
+	assert(ObjGetLen(bo->fetch_objcore, bo->wrk->stats) == al);
 	EXP_Rearm(bo->ims_oc, bo->ims_oc->exp.t_origin, 0, 0, 0);
 
 	/* Recycle the backend connection before setting BOS_FINISHED to
@@ -778,11 +777,10 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
 
 	VFP_Setup(bo->vfc);
 	bo->vfc->bo = bo;
+	bo->vfc->wrk = bo->wrk;
 	bo->vfc->oc = bo->fetch_objcore;
-	bo->vfc->stats = bo->stats;
 	bo->vfc->http = bo->beresp;
 	bo->vfc->esi_req = bo->bereq;
-	bo->vfc->vsl = bo->vsl;
 
 	if (vbf_beresp2obj(bo))
 		return (F_STP_FAIL);
@@ -857,7 +855,6 @@ vbf_fetch_thread(struct worker *wrk, void *priv)
 	assert(isnan(bo->t_prev));
 	VSLb_ts_busyobj(bo, "Start", W_TIM_real(wrk));
 
-	bo->stats = wrk->stats;
 	bo->wrk = wrk;
 	wrk->vsl = bo->vsl;
 
@@ -892,14 +889,13 @@ vbf_fetch_thread(struct worker *wrk, void *priv)
 		AZ(bo->fetch_objcore->flags & OC_F_FAILED);
 		HSH_Complete(bo->fetch_objcore);
 		VSLb(bo->vsl, SLT_Length, "%ju",
-		    (uintmax_t)ObjGetLen(bo->fetch_objcore, bo->stats));
+		    (uintmax_t)ObjGetLen(bo->fetch_objcore, bo->wrk->stats));
 	}
 	AZ(bo->fetch_objcore->busyobj);
 
 	if (bo->ims_oc != NULL)
 		(void)HSH_DerefObjCore(wrk->stats, &bo->ims_oc);
 
-	bo->stats = NULL;
 
 	wrk->vsl = NULL;
 	VBO_DerefBusyObj(wrk, &bo);
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index 9cf0aa4..3e3aad6 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -60,7 +60,7 @@ VFP_Error(struct vfp_ctx *vc, const char *fmt, ...)
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
 	if (!vc->failed) {
 		va_start(ap, fmt);
-		VSLbv(vc->vsl, SLT_FetchError, fmt, ap);
+		VSLbv(vc->wrk->vsl, SLT_FetchError, fmt, ap);
 		va_end(ap);
 		vc->failed = 1;
 	}
@@ -77,19 +77,19 @@ VFP_GetStorage(struct vfp_ctx *vc, ssize_t *sz, uint8_t **ptr)
 {
 	ssize_t l;
 
+
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
 	AN(sz);
 	assert(*sz >= 0);
 	AN(ptr);
 
-	AN(vc->stats);
 	l = fetchfrag;
 	if (l == 0)
 		l = *sz;
 	if (l == 0)
 		l = cache_param->fetch_chunksize;
 	*sz = l;
-	if (!ObjGetSpace(vc->oc, vc->vsl, vc->stats, sz, ptr)) {
+	if (!ObjGetSpace(vc->oc, vc->wrk, sz, ptr)) {
 		*sz = 0;
 		*ptr = NULL;
 		return (VFP_Error(vc, "Could not get storage"));
@@ -121,7 +121,7 @@ VFP_Close(struct vfp_ctx *vc)
 	VTAILQ_FOREACH(vfe, &vc->vfp, list) {
 		if(vfe->vfp->fini != NULL)
 			vfe->vfp->fini(vc, vfe);
-		VSLb(vc->vsl, SLT_VfpAcct, "%s %ju %ju",
+		VSLb(vc->wrk->vsl, SLT_VfpAcct, "%s %ju %ju",
 			vfe->vfp->name, vfe->calls, vfe->bytes_out);
 	}
 }
@@ -133,7 +133,8 @@ VFP_Open(struct vfp_ctx *vc)
 
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
 	CHECK_OBJ_NOTNULL(vc->http, HTTP_MAGIC);
-	AN(vc->vsl);
+	CHECK_OBJ_NOTNULL(vc->wrk, WORKER_MAGIC);
+	AN(vc->wrk->vsl);
 
 	VTAILQ_FOREACH_REVERSE(vfe, &vc->vfp, vfp_entry_s, list) {
 		if (vfe->vfp->init == NULL)
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 1e5b806..a4b3034 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -469,11 +469,11 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
 	if (vfe->vfp->priv2 == VFP_GZIP) {
 		if (http_GetHdr(vc->http, H_Content_Encoding, NULL))
 			return (VFP_NULL);
-		vg = VGZ_NewGzip(vc->vsl, vfe->vfp->priv1);
+		vg = VGZ_NewGzip(vc->wrk->vsl, vfe->vfp->priv1);
 	} else {
 		if (!http_HdrIs(vc->http, H_Content_Encoding, "gzip"))
 			return (VFP_NULL);
-		vg = VGZ_NewUngzip(vc->vsl, vfe->vfp->priv1);
+		vg = VGZ_NewUngzip(vc->wrk->vsl, vfe->vfp->priv1);
 	}
 	if (vg == NULL)
 		return (VFP_ERROR);
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index f846541..2c5335c 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -213,8 +213,7 @@ ObjIterEnd(struct objcore *oc, void **oix)
  */
 
 static struct storage *
-objallocwithnuke(struct stevedore *stv, struct vsl_log *vsl, struct dstat *ds,
-    size_t size)
+objallocwithnuke(struct stevedore *stv, struct worker *wrk, size_t size)
 {
 	struct storage *st = NULL;
 	unsigned fail;
@@ -235,7 +234,7 @@ objallocwithnuke(struct stevedore *stv, struct vsl_log *vsl, struct dstat *ds,
 
 		/* no luck; try to free some space and keep trying */
 		if (fail < cache_param->nuke_limit &&
-		    EXP_NukeOne(vsl, ds, stv->lru) == -1)
+		    EXP_NukeOne(wrk, stv->lru) == -1)
 			break;
 	}
 	CHECK_OBJ_ORNULL(st, STORAGE_MAGIC);
@@ -252,22 +251,21 @@ objallocwithnuke(struct stevedore *stv, struct vsl_log *vsl, struct dstat *ds,
  */
 
 int
-ObjGetSpace(struct objcore *oc, struct vsl_log *vsl, struct dstat *ds,
-    ssize_t *sz, uint8_t **ptr)
+ObjGetSpace(struct objcore *oc, struct worker *wrk, ssize_t *sz, uint8_t **ptr)
 {
 	struct object *o;
 	struct storage *st;
 	const struct storeobj_methods *om = obj_getmethods(oc);
 
 	if (om->objgetspace != NULL)
-		return (om->objgetspace(oc, vsl, ds, sz, ptr));
+		return (om->objgetspace(oc, wrk, sz, ptr));
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	AN(ds);
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	AN(sz);
 	AN(ptr);
 	assert(*sz > 0);
-	o = obj_getobj(oc, ds);
+	o = obj_getobj(oc, wrk->stats);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 
 	st = VTAILQ_LAST(&o->list, storagehead);
@@ -278,7 +276,7 @@ ObjGetSpace(struct objcore *oc, struct vsl_log *vsl, struct dstat *ds,
 		return (1);
 	}
 
-	st = objallocwithnuke(oc->stobj->stevedore, vsl, ds, *sz);
+	st = objallocwithnuke(oc->stobj->stevedore, wrk, *sz);
 	if (st == NULL)
 		return (0);
 
@@ -529,13 +527,13 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, ssize_t len,
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
 	CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC);
 	CHECK_OBJ_NOTNULL(vc->oc, OBJCORE_MAGIC);
-	o = obj_getobj(vc->oc, vc->stats);
+	o = obj_getobj(vc->oc, vc->wrk->stats);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	st = o->objstore;
 	switch (attr) {
 	case OA_ESIDATA:
-		o->esidata = objallocwithnuke(vc->oc->stobj->stevedore, vc->vsl,
-		    vc->stats, len);
+		o->esidata = objallocwithnuke(vc->oc->stobj->stevedore,
+		    vc->wrk, len);
 		if (o->esidata == NULL)
 			return (NULL);
 		o->esidata->len = len;
@@ -592,7 +590,7 @@ ObjCopyAttr(const struct vfp_ctx *vc, struct objcore *ocs, enum obj_attr attr)
 
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
 
-	vps = ObjGetattr(ocs, vc->stats, attr, &l);
+	vps = ObjGetattr(ocs, vc->wrk->stats, attr, &l);
 	// XXX: later we want to have zero-length OA's too
 	if (vps == NULL || l <= 0)
 		return (-1);
diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c
index 1befd7d..049e850 100644
--- a/bin/varnishd/cache/cache_req_body.c
+++ b/bin/varnishd/cache/cache_req_body.c
@@ -105,7 +105,7 @@ VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv)
 	vfc = req->htc->vfc;
 	VFP_Setup(vfc);
 	vfc->http = req->http;
-	vfc->vsl = req->vsl;
+	vfc->wrk = req->wrk;
 	V1F_Setup_Fetch(vfc, req->htc);
 	if (VFP_Open(vfc) < 0) {
 		VSLb(req->vsl, SLT_FetchError, "Could not open Fetch Pipeline");
@@ -222,14 +222,13 @@ VRB_Cache(struct req *req, ssize_t maxsize)
 	}
 
 	req->body_oc = HSH_NewObjCore(req->wrk);
-	XXXAN(STV_NewObject(req->body_oc, req->vsl, req->wrk->stats,
-	    TRANSIENT_STORAGE, 8));
+	AN(req->body_oc);
+	XXXAN(STV_NewObject(req->body_oc, req->wrk, TRANSIENT_STORAGE, 8));
 
 	VFP_Setup(vfc);
 	vfc->http = req->http;
-	vfc->vsl = req->vsl;
+	vfc->wrk = req->wrk;
 	vfc->oc = req->body_oc;
-	vfc->stats = req->wrk->stats;
 	V1F_Setup_Fetch(vfc, req->htc);
 
 	if (VFP_Open(vfc) < 0) {
@@ -237,6 +236,7 @@ VRB_Cache(struct req *req, ssize_t maxsize)
 		return (-1);
 	}
 
+	AN(req->htc);
 	yet = req->htc->content_length;
 	if (yet < 0)
 		yet = 0;
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index 03f599a..2e02e0a 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -245,7 +245,7 @@ stv_default_allocobj(struct stevedore *stv, struct objcore *oc, unsigned ltot)
  */
 
 int
-STV_NewObject(struct objcore *oc, struct vsl_log *vsl, struct dstat *stats,
+STV_NewObject(struct objcore *oc, struct worker *wrk,
     const char *hint, unsigned wsl)
 {
 	struct stevedore *stv, *stv0;
@@ -253,19 +253,18 @@ STV_NewObject(struct objcore *oc, struct vsl_log *vsl, struct dstat *stats,
 	int i, j;
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	AN(vsl);
-	AN(stats);
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	assert(wsl > 0);
 	wsl = PRNDUP(wsl);
 
 	ltot = sizeof(struct object) + wsl;
 
-	stv = stv0 = stv_pick_stevedore(vsl, &hint);
+	stv = stv0 = stv_pick_stevedore(wrk->vsl, &hint);
 	AN(stv->allocobj);
 	j = stv->allocobj(stv, oc, ltot);
 	if (j == 0 && hint == NULL) {
 		do {
-			stv = stv_pick_stevedore(vsl, &hint);
+			stv = stv_pick_stevedore(wrk->vsl, &hint);
 			AN(stv->allocobj);
 			j = stv->allocobj(stv, oc, ltot);
 		} while (j == 0 && stv != stv0);
@@ -273,7 +272,7 @@ STV_NewObject(struct objcore *oc, struct vsl_log *vsl, struct dstat *stats,
 	if (j == 0) {
 		/* no luck; try to free some space and keep trying */
 		for (i = 0; j == 0 && i < cache_param->nuke_limit; i++) {
-			if (EXP_NukeOne(vsl, stats, stv->lru) == -1)
+			if (EXP_NukeOne(wrk, stv->lru) == -1)
 				break;
 			j = stv->allocobj(stv, oc, ltot);
 		}
@@ -282,8 +281,8 @@ STV_NewObject(struct objcore *oc, struct vsl_log *vsl, struct dstat *stats,
 	if (j == 0)
 		return (0);
 
-	stats->n_object++;
-	VSLb(vsl, SLT_Storage, "%s %s",
+	wrk->stats->n_object++;
+	VSLb(wrk->vsl, SLT_Storage, "%s %s",
 	    oc->stobj->stevedore->name, oc->stobj->stevedore->ident);
 	return (1);
 }
diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h
index 9ddd770..cc3420a 100644
--- a/bin/varnishd/storage/storage.h
+++ b/bin/varnishd/storage/storage.h
@@ -99,8 +99,8 @@ typedef void *objiterbegin_f(struct objcore *oc, struct worker *wrk);
 typedef enum objiter_status objiter_f(struct objcore *oc, void *oix,
     void **p, ssize_t *l);
 typedef void objiterend_f(struct objcore *oc, void **oix);
-typedef int objgetspace_f(struct objcore *oc, struct vsl_log *vsl,
-    struct dstat *ds, ssize_t *sz, uint8_t **ptr);
+typedef int objgetspace_f(struct objcore *oc, struct worker *,
+     ssize_t *sz, uint8_t **ptr);
 typedef void objextend_f(struct objcore *oc, struct dstat *ds, ssize_t l);
 typedef void objtrimstore_f(struct objcore *oc, struct dstat *ds);
 typedef void objslim_f(struct objcore *oc, struct dstat *ds);



More information about the varnish-commit mailing list