[master] 08fe2b8 Make the reference req/busyobj and a few other bits hold in VCL's a pointer to our internal housekeeping structure, rather than the VCL_conf stucture.

Poul-Henning Kamp phk at FreeBSD.org
Wed Jun 17 11:39:04 CEST 2015


commit 08fe2b87a62a68fa3629619aac693f2b8467c2ca
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Jun 17 08:57:52 2015 +0000

    Make the reference req/busyobj and a few other bits hold in VCL's
    a pointer to our internal housekeeping structure, rather than the
    VCL_conf stucture.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index e8836fb..49bf6ba 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -341,7 +341,7 @@ struct worker {
 
 	pthread_cond_t		cond;
 
-	struct VCL_conf		*vcl;
+	struct vcl		*vcl;
 
 	struct ws		aws[1];
 
@@ -503,7 +503,7 @@ struct busyobj {
 	const struct director	*director_req;
 	const struct director	*director_resp;
 	enum director_state_e	director_state;
-	struct VCL_conf		*vcl;
+	struct vcl		*vcl;
 
 	struct vsl_log		vsl[1];
 
@@ -560,7 +560,7 @@ struct req {
 	const char		*err_reason;
 
 	const struct director	*director_hint;
-	struct VCL_conf		*vcl;
+	struct vcl		*vcl;
 
 	char			*ws_req;	/* WS above request data */
 
@@ -1065,19 +1065,19 @@ enum vry_finish_flag { KEEP, DISCARD };
 void VRY_Finish(struct req *req, enum vry_finish_flag);
 
 /* cache_vcl.c */
-struct director *VCL_DefaultDirector(const struct VCL_conf *);
+struct director *VCL_DefaultDirector(const struct vcl *);
 void VCL_Init(void);
 const char *VCL_Method_Name(unsigned);
-const char *VCL_Name(const struct VCL_conf *);
-void VCL_Panic(struct vsb *, const struct VCL_conf *);
+const char *VCL_Name(const struct vcl *);
+void VCL_Panic(struct vsb *, const struct vcl *);
 void VCL_Poll(void);
-void VCL_Ref(struct VCL_conf *);
-void VCL_Refresh(struct VCL_conf **);
-void VCL_Rel(struct VCL_conf **);
+void VCL_Ref(struct vcl *);
+void VCL_Refresh(struct vcl **);
+void VCL_Rel(struct vcl **);
 const char *VCL_Return_Name(unsigned);
 
 #define VCL_MET_MAC(l,u,b) \
-    void VCL_##l##_method(struct VCL_conf *, struct worker *, struct req *, \
+    void VCL_##l##_method(struct vcl *, struct worker *, struct req *, \
 	struct busyobj *bo, void *specific);
 #include "tbl/vcl_returns.h"
 #undef VCL_MET_MAC
diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c
index fc15baa..9f831b4 100644
--- a/bin/varnishd/cache/cache_backend_cfg.c
+++ b/bin/varnishd/cache/cache_backend_cfg.c
@@ -152,7 +152,7 @@ backend_find(struct cli *cli, const char *matcher, bf_func *func, void *priv)
 {
 	int i, found = 0;
 	struct vsb *vsb;
-	struct VCL_conf *vcc = NULL;
+	struct vcl *vcc = NULL;
 	struct backend *b;
 
 	VCL_Refresh(&vcc);
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 3e13dd2..3eed33b 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -978,7 +978,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
 
 	oc->busyobj = bo;
 
-	CHECK_OBJ_NOTNULL(bo->vcl, VCL_CONF_MAGIC);
+	AN(bo->vcl);
 
 	if (mode == VBF_PASS)
 		bo->do_pass = 1;
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index bca73c2..4f1ad1d 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -46,7 +46,7 @@
 
 struct vcl {
 	unsigned		magic;
-#define VVCLS_MAGIC		0x214188f2
+#define VCL_MAGIC		0x214188f2
 	VTAILQ_ENTRY(vcl)	list;
 	void			*dlh;
 	struct VCL_conf		conf[1];
@@ -67,7 +67,7 @@ static struct vcl		*vcl_active; /* protected by vcl_mtx */
 /*--------------------------------------------------------------------*/
 
 void
-VCL_Panic(struct vsb *vsb, const struct VCL_conf *vcl)
+VCL_Panic(struct vsb *vsb, const struct vcl *vcl)
 {
 	int i;
 
@@ -76,8 +76,8 @@ VCL_Panic(struct vsb *vsb, const struct VCL_conf *vcl)
 		return;
 	VSB_printf(vsb, "  vcl = {\n");
 	VSB_printf(vsb, "    srcname = {\n");
-	for (i = 0; i < vcl->nsrc; ++i)
-		VSB_printf(vsb, "      \"%s\",\n", vcl->srcname[i]);
+	for (i = 0; i < vcl->conf->nsrc; ++i)
+		VSB_printf(vsb, "      \"%s\",\n", vcl->conf->srcname[i]);
 	VSB_printf(vsb, "    },\n");
 	VSB_printf(vsb, "  },\n");
 }
@@ -113,7 +113,7 @@ VCL_Method_Name(unsigned m)
 /*--------------------------------------------------------------------*/
 
 static void
-VCL_Get(struct VCL_conf **vcc)
+VCL_Get(struct vcl **vcc)
 {
 	static int once = 0;
 
@@ -124,17 +124,17 @@ VCL_Get(struct VCL_conf **vcc)
 
 	Lck_Lock(&vcl_mtx);
 	AN(vcl_active);
-	*vcc = vcl_active->conf;
+	*vcc = vcl_active;
 	AN(*vcc);
-	AZ((*vcc)->discard);
-	(*vcc)->busy++;
+	AZ((*vcc)->conf->discard);
+	(*vcc)->conf->busy++;
 	Lck_Unlock(&vcl_mtx);
 }
 
 void
-VCL_Refresh(struct VCL_conf **vcc)
+VCL_Refresh(struct vcl **vcc)
 {
-	if (*vcc == vcl_active->conf)
+	if (*vcc == vcl_active)
 		return;
 	if (*vcc != NULL)
 		VCL_Rel(vcc);	/* XXX: optimize locking */
@@ -142,27 +142,27 @@ VCL_Refresh(struct VCL_conf **vcc)
 }
 
 void
-VCL_Ref(struct VCL_conf *vc)
+VCL_Ref(struct vcl *vc)
 {
 
 	Lck_Lock(&vcl_mtx);
-	assert(vc->busy > 0);
-	vc->busy++;
+	assert(vc->conf->busy > 0);
+	vc->conf->busy++;
 	Lck_Unlock(&vcl_mtx);
 }
 
 void
-VCL_Rel(struct VCL_conf **vcc)
+VCL_Rel(struct vcl **vcc)
 {
-	struct VCL_conf *vc;
+	struct vcl *vc;
 
 	AN(*vcc);
 	vc = *vcc;
 	*vcc = NULL;
 
 	Lck_Lock(&vcl_mtx);
-	assert(vc->busy > 0);
-	vc->busy--;
+	assert(vc->conf->busy > 0);
+	vc->conf->busy--;
 	/*
 	 * We do not garbage collect discarded VCL's here, that happens
 	 * in VCL_Poll() which is called from the CLI thread.
@@ -199,7 +199,7 @@ VCL_Open(const char *fn, struct vsb *msg)
 		(void)dlclose(dlh);
 		return (NULL);
 	}
-	ALLOC_OBJ(vcl, VVCLS_MAGIC);
+	ALLOC_OBJ(vcl, VCL_MAGIC);
 	AN(vcl);
 	vcl->dlh = dlh;
 	memcpy(vcl->conf, cnf, sizeof *cnf);
@@ -211,7 +211,7 @@ VCL_Close(struct vcl **vclp)
 {
 	struct vcl *vcl;
 
-	CHECK_OBJ_NOTNULL(*vclp, VVCLS_MAGIC);
+	CHECK_OBJ_NOTNULL(*vclp, VCL_MAGIC);
 	vcl = *vclp;
 	*vclp = NULL;
 	AZ(dlclose(vcl->dlh));
@@ -246,18 +246,18 @@ VCL_TestLoad(const char *fn)
 /*--------------------------------------------------------------------*/
 
 struct director *
-VCL_DefaultDirector(const struct VCL_conf *vcc)
+VCL_DefaultDirector(const struct vcl *vcc)
 {
 
 	AN(vcc);
-	return (*vcc->default_director);
+	return (*vcc->conf->default_director);
 }
 
 const char *
-VCL_Name(const struct VCL_conf *vcc)
+VCL_Name(const struct vcl *vcc)
 {
 	AN(vcc);
-	return (vcc->loaded_name);
+	return (vcc->conf->loaded_name);
 }
 
 /*--------------------------------------------------------------------*/
@@ -570,7 +570,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
 		CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 		CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC);
 		vsl = req->vsl;
-		ctx.vcl = req->vcl;
+		ctx.vcl = req->vcl->conf;
 		ctx.http_req = req->http;
 		ctx.http_req_top = req->top->http;
 		ctx.http_resp = req->resp;
@@ -581,7 +581,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
 	if (bo != NULL) {
 		CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 		vsl = bo->vsl;
-		ctx.vcl = bo->vcl;
+		ctx.vcl = bo->vcl->conf;
 		ctx.http_bereq = bo->bereq;
 		ctx.http_beresp = bo->beresp;
 		ctx.bo = bo;
@@ -612,14 +612,15 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
 
 #define VCL_MET_MAC(func, upper, bitmap)				\
 void									\
-VCL_##func##_method(struct VCL_conf *vcl, struct worker *wrk,		\
+VCL_##func##_method(struct vcl *vcl, struct worker *wrk,		\
      struct req *req, struct busyobj *bo, void *specific)		\
 {									\
 									\
-	CHECK_OBJ_NOTNULL(vcl, VCL_CONF_MAGIC);				\
+	CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);				\
+	CHECK_OBJ_NOTNULL(vcl->conf, VCL_CONF_MAGIC);			\
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);				\
 	vcl_call_method(wrk, req, bo, specific,				\
-	    VCL_MET_ ## upper, vcl->func##_func);			\
+	    VCL_MET_ ## upper, vcl->conf->func##_func);			\
 	AN((1U << wrk->handling) & bitmap);				\
 }
 



More information about the varnish-commit mailing list