[master] 967af89 Pass struct req into VCL methods

Poul-Henning Kamp phk at varnish-cache.org
Thu Jun 14 15:19:56 CEST 2012


commit 967af895463e08ffa7fb69041f6872608fba4d5c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jun 14 12:25:52 2012 +0000

    Pass struct req into VCL methods

diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 527c591..b909a0e 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -191,7 +191,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli)
 	REPLACE(vcl->name, name);
 	VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name);
 	VTAILQ_INSERT_TAIL(&vcl_head, vcl, list);
-	(void)vcl->conf->init_func(NULL);
+	(void)vcl->conf->init_func(NULL, NULL);
 	Lck_Lock(&vcl_mtx);
 	if (vcl_active == NULL)
 		vcl_active = vcl;
@@ -215,7 +215,7 @@ VCL_Nuke(struct vcls *vcl)
 	assert(vcl->conf->discard);
 	assert(vcl->conf->busy == 0);
 	VTAILQ_REMOVE(&vcl_head, vcl, list);
-	(void)vcl->conf->fini_func(NULL);
+	(void)vcl->conf->fini_func(NULL, NULL);
 	vcl->conf->fini_vcl(NULL);
 	free(vcl->name);
 	(void)dlclose(vcl->dlh);
@@ -344,7 +344,7 @@ VCL_##func##_method(struct req *req)					\
 	req->handling = 0;						\
 	req->cur_method = VCL_MET_ ## upper;				\
 	VSLb(req->vsl, SLT_VCL_call, "%s", #func);			\
-	(void)req->vcl->func##_func(req->sp);				\
+	(void)req->vcl->func##_func(req->sp, req);			\
 	VSLb(req->vsl, SLT_VCL_return, "%s",				\
 	    VCL_Return_Name(req->handling));				\
 	req->cur_method = 0;						\
diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py
index 1d397c8..0f7b360 100755
--- a/lib/libvcl/generate.py
+++ b/lib/libvcl/generate.py
@@ -716,11 +716,12 @@ file_header(fo)
 
 fo.write("""
 struct sess;
+struct req;
 struct cli;
 
 typedef int vcl_init_f(struct cli *);
 typedef void vcl_fini_f(struct cli *);
-typedef int vcl_func_f(struct sess *sp);
+typedef int vcl_func_f(struct sess *sp, struct req *req);
 """)
 
 
diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c
index c9fe573..db8b37a 100644
--- a/lib/libvcl/vcc_compile.c
+++ b/lib/libvcl/vcc_compile.c
@@ -670,7 +670,7 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp)
 	/* Emit method functions */
 	for (i = 0; i < VCL_MET_MAX; i++) {
 		Fc(tl, 1, "\nstatic int\n");
-		Fc(tl, 1, "VGC_function_%s (struct sess *sp)\n",
+		Fc(tl, 1, "VGC_function_%s(struct sess *sp, struct req *req)\n",
 		    method_tab[i].name);
 		AZ(VSB_finish(tl->fm[i]));
 		Fc(tl, 1, "{\n");
diff --git a/lib/libvcl/vcc_parse.c b/lib/libvcl/vcc_parse.c
index 1b7ee88..1d37dd5 100644
--- a/lib/libvcl/vcc_parse.c
+++ b/lib/libvcl/vcc_parse.c
@@ -224,10 +224,13 @@ vcc_Function(struct vcc *tl)
 			return;
 		}
 		tl->curproc = vcc_AddProc(tl, tl->t);
-		Fh(tl, 0, "static int VGC_function_%.*s (struct sess *sp);\n",
+		Fh(tl, 0, "static int VGC_function_%.*s "
+		    "(struct sess *, struct req *);\n",
 		    PF(tl->t));
 		Fc(tl, 1, "\nstatic int\n");
-		Fc(tl, 1, "VGC_function_%.*s (struct sess *sp)\n", PF(tl->t));
+		Fc(tl, 1, "VGC_function_%.*s"
+		    "(struct sess *sp, struct req *req)\n",
+		    PF(tl->t));
 	}
 	vcc_NextToken(tl);
 	tl->indent += INDENT;



More information about the varnish-commit mailing list