[master] c72cfed Make the VCL reference in vrt_ctx point to our internal housekeeping rather than the compile config structure.
Poul-Henning Kamp
phk at FreeBSD.org
Wed Jun 17 11:39:04 CEST 2015
commit c72cfed759692baf3a43f852470846f6e071ccc9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Jun 17 09:19:15 2015 +0000
Make the VCL reference in vrt_ctx point to our internal
housekeeping rather than the compile config structure.
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 2df74c2..2720710 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -308,9 +308,9 @@ VRT_init_vbe(VRT_CTX, struct director **dp, const struct vrt_backend *vrt)
AN(dp);
AZ(*dp);
CHECK_OBJ_NOTNULL(vrt, VRT_BACKEND_MAGIC);
- CHECK_OBJ_NOTNULL(ctx->vcl, VCL_CONF_MAGIC);
+ AN(ctx->vcl);
- be = VBE_AddBackend(ctx->vcl->loaded_name, vrt);
+ be = VBE_AddBackend(ctx, vrt);
AN(be);
ALLOC_OBJ(d, DIRECTOR_MAGIC);
XXXAN(d);
diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h
index d7c9aac..6c9f82b 100644
--- a/bin/varnishd/cache/cache_backend.h
+++ b/bin/varnishd/cache/cache_backend.h
@@ -39,6 +39,7 @@
struct vbp_target;
struct vbc;
+struct vrt_ctx;
struct vrt_backend_probe;
struct tcp_pool;
@@ -105,7 +106,8 @@ struct vbc {
/* cache_backend_cfg.c */
unsigned VBE_Healthy(const struct backend *b, double *changed);
-struct backend *VBE_AddBackend(const char *vcl, const struct vrt_backend *vb);
+struct backend *VBE_AddBackend(const struct vrt_ctx *,
+ const struct vrt_backend *);
void VBE_DeleteBackend(struct backend *);
/* cache_backend_poll.c */
diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c
index 9f831b4..16cc55c 100644
--- a/bin/varnishd/cache/cache_backend_cfg.c
+++ b/bin/varnishd/cache/cache_backend_cfg.c
@@ -76,11 +76,13 @@ VBE_DeleteBackend(struct backend *b)
*/
struct backend *
-VBE_AddBackend(const char *vcl, const struct vrt_backend *vb)
+VBE_AddBackend(const struct vrt_ctx *ctx, const struct vrt_backend *vb)
{
struct backend *b;
char buf[128];
+ struct vcl *vcl;
+ vcl = ctx->vcl;
AN(vb->vcl_name);
assert(vb->ipv4_suckaddr != NULL || vb->ipv6_suckaddr != NULL);
@@ -89,7 +91,7 @@ VBE_AddBackend(const char *vcl, const struct vrt_backend *vb)
XXXAN(b);
Lck_New(&b->mtx, lck_backend);
- bprintf(buf, "%s.%s", vcl, vb->vcl_name);
+ bprintf(buf, "%s.%s", VCL_Name(vcl), vb->vcl_name);
REPLACE(b->display_name, buf);
b->vcl_name = vb->vcl_name;
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 4f1ad1d..0717bcb 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -262,6 +262,20 @@ VCL_Name(const struct vcl *vcc)
/*--------------------------------------------------------------------*/
+void
+VRT_count(VRT_CTX, unsigned u)
+{
+
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx->vcl, VCL_MAGIC);
+ assert(u < ctx->vcl->conf->nref);
+ if (ctx->vsl != NULL)
+ VSLb(ctx->vsl, SLT_VCL_trace, "%u %u.%u", u,
+ ctx->vcl->conf->ref[u].line, ctx->vcl->conf->ref[u].pos);
+}
+
+/*--------------------------------------------------------------------*/
+
static struct vcl *
vcl_find(const char *name)
{
@@ -332,7 +346,7 @@ VCL_Load(struct cli *cli, const char *name, const char *fn, const char *state)
INIT_OBJ(&ctx, VRT_CTX_MAGIC);
ctx.method = VCL_MET_INIT;
ctx.handling = &hand;
- ctx.vcl = vcl->conf;
+ ctx.vcl = vcl;
VSB_clear(vsb);
ctx.msg = vsb;
@@ -380,7 +394,7 @@ VCL_Nuke(struct vcl *vcl)
VTAILQ_REMOVE(&vcl_head, vcl, list);
ctx.method = VCL_MET_FINI;
ctx.handling = &hand;
- ctx.vcl = vcl->conf;
+ ctx.vcl = vcl;
AZ(vcl->conf->event_vcl(&ctx, VCL_EVENT_DISCARD));
free(vcl->conf->loaded_name);
VCL_Close(&vcl);
@@ -569,8 +583,9 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
if (req != NULL) {
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(req->vcl, VCL_MAGIC);
vsl = req->vsl;
- ctx.vcl = req->vcl->conf;
+ ctx.vcl = req->vcl;
ctx.http_req = req->http;
ctx.http_req_top = req->top->http;
ctx.http_resp = req->resp;
@@ -580,8 +595,9 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
}
if (bo != NULL) {
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+ CHECK_OBJ_NOTNULL(bo->vcl, VCL_MAGIC);
vsl = bo->vsl;
- ctx.vcl = bo->vcl->conf;
+ ctx.vcl = bo->vcl;
ctx.http_bereq = bo->bereq;
ctx.http_beresp = bo->beresp;
ctx.bo = bo;
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 9b4aaff..df6bb96 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -65,18 +65,6 @@ VRT_error(VRT_CTX, unsigned code, const char *reason)
/*--------------------------------------------------------------------*/
void
-VRT_count(VRT_CTX, unsigned u)
-{
-
- CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
- if (ctx->vsl != NULL)
- VSLb(ctx->vsl, SLT_VCL_trace, "%u %u.%u", u,
- ctx->vcl->ref[u].line, ctx->vcl->ref[u].pos);
-}
-
-/*--------------------------------------------------------------------*/
-
-void
VRT_acl_log(VRT_CTX, const char *msg)
{
diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c
index b4676bc..22b45de 100644
--- a/bin/varnishd/cache/cache_vrt_priv.c
+++ b/bin/varnishd/cache/cache_vrt_priv.c
@@ -43,7 +43,7 @@ struct vrt_priv {
#define VRT_PRIV_MAGIC 0x24157a52
VTAILQ_ENTRY(vrt_priv) list;
struct vmod_priv priv[1];
- const struct VCL_conf *vcl;
+ const struct vcl *vcl;
uintptr_t id;
uintptr_t vmod_id;
};
diff --git a/include/vrt.h b/include/vrt.h
index cbed87b..2ac390e 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -49,16 +49,17 @@
/***********************************************************************/
-struct req;
+struct VCL_conf;
struct busyobj;
-struct vsl_log;
-struct http;
-struct ws;
-struct vsb;
struct director;
-struct VCL_conf;
+struct http;
+struct req;
struct suckaddr;
+struct vcl;
struct vmod;
+struct vsb;
+struct vsl_log;
+struct ws;
/***********************************************************************
* This is the central definition of the mapping from VCL types to
@@ -95,7 +96,7 @@ struct vrt_ctx {
struct vsb *msg; // Only in ...init()
struct vsl_log *vsl;
- struct VCL_conf *vcl;
+ struct vcl *vcl;
struct ws *ws;
struct req *req;
More information about the varnish-commit
mailing list