[master] 14b48c8 More VRT sess->req changes

Poul-Henning Kamp phk at varnish-cache.org
Mon Jun 18 14:27:31 CEST 2012


commit 14b48c8f8a9222689cef12d5fe9f19dc87a5eaa6
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jun 18 12:27:22 2012 +0000

    More VRT sess->req changes

diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index d288e3d..bfb030d 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -506,15 +506,16 @@ hsh_rush(struct dstat *ds, struct objhead *oh)
  */
 
 void
-HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace)
+HSH_Purge(struct req *req, struct objhead *oh, double ttl, double grace)
 {
 	struct objcore *oc, **ocp;
 	unsigned spc, nobj, n;
 	struct object *o;
 
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
-	spc = WS_Reserve(sp->req->ws, 0);
-	ocp = (void*)sp->req->ws->f;
+	spc = WS_Reserve(req->ws, 0);
+	ocp = (void*)req->ws->f;
 	Lck_Lock(&oh->mtx);
 	assert(oh->refcnt > 0);
 	nobj = 0;
@@ -531,7 +532,8 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace)
 			continue;
 		}
 
-		(void)oc_getobj(&sp->wrk->stats, oc); /* XXX: still needed ? */
+		(void)oc_getobj(&req->sp->wrk->stats, oc);
+		    /* XXX: still needed ? */
 
 		xxxassert(spc >= sizeof *ocp);
 		oc->refcnt++;
@@ -548,16 +550,16 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace)
 	for (n = 0; n < nobj; n++) {
 		oc = ocp[n];
 		CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-		o = oc_getobj(&sp->wrk->stats, oc);
+		o = oc_getobj(&req->sp->wrk->stats, oc);
 		if (o == NULL)
 			continue;
 		CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 		o->exp.ttl = ttl;
 		o->exp.grace = grace;
 		EXP_Rearm(o);
-		(void)HSH_Deref(&sp->wrk->stats, NULL, &o);
+		(void)HSH_Deref(&req->sp->wrk->stats, NULL, &o);
 	}
-	WS_Release(sp->req->ws, 0);
+	WS_Release(req->ws, 0);
 }
 
 
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index b909a0e..07c1687 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, NULL);
+	(void)vcl->conf->init_func(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, NULL);
+	(void)vcl->conf->fini_func(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, req);			\
+	(void)req->vcl->func##_func(req);				\
 	VSLb(req->vsl, SLT_VCL_return, "%s",				\
 	    VCL_Return_Name(req->handling));				\
 	req->cur_method = 0;						\
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index f172769..8cc2920 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -286,7 +286,7 @@ VRT_r_now(const struct req *req)
 /*--------------------------------------------------------------------*/
 
 char *
-VRT_IP_string(struct req *req, const struct sockaddr_storage *sa)
+VRT_IP_string(const struct req *req, const struct sockaddr_storage *sa)
 {
 	char *p;
 	const struct sockaddr_in *si4;
@@ -316,7 +316,7 @@ VRT_IP_string(struct req *req, const struct sockaddr_storage *sa)
 }
 
 char *
-VRT_int_string(struct req *req, int num)
+VRT_int_string(const struct req *req, int num)
 {
 	char *p;
 	int size;
@@ -329,7 +329,7 @@ VRT_int_string(struct req *req, int num)
 }
 
 char *
-VRT_double_string(struct req *req, double num)
+VRT_double_string(const struct req *req, double num)
 {
 	char *p;
 	int size;
@@ -342,7 +342,7 @@ VRT_double_string(struct req *req, double num)
 }
 
 char *
-VRT_time_string(struct req *req, double t)
+VRT_time_string(const struct req *req, double t)
 {
 	char *p;
 
@@ -375,17 +375,18 @@ VRT_bool_string(const struct req *req, unsigned val)
 /*--------------------------------------------------------------------*/
 
 void
-VRT_Rollback(const struct sess *sp)
+VRT_Rollback(struct req *req)
 {
 
-	HTTP_Copy(sp->req->http, sp->req->http0);
-	WS_Reset(sp->req->ws, sp->req->ws_req);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	HTTP_Copy(req->http, req->http0);
+	WS_Reset(req->ws, req->ws_req);
 }
 
 /*--------------------------------------------------------------------*/
 
 void
-VRT_synth_page(struct req *req, unsigned flags, const char *str, ...)
+VRT_synth_page(const struct req *req, unsigned flags, const char *str, ...)
 {
 	va_list ap;
 	const char *p;
@@ -415,14 +416,14 @@ VRT_synth_page(struct req *req, unsigned flags, const char *str, ...)
 /*--------------------------------------------------------------------*/
 
 void
-VRT_ban(struct sess *sp, char *cmds, ...)
+VRT_ban(const struct req *req, char *cmds, ...)
 {
 	char *a1, *a2, *a3;
 	va_list ap;
 	struct ban *b;
 	int good;
 
-	(void)sp;
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	b = BAN_New();
 	va_start(ap, cmds);
 	a1 = cmds;
@@ -450,7 +451,7 @@ VRT_ban(struct sess *sp, char *cmds, ...)
 /*--------------------------------------------------------------------*/
 
 void
-VRT_ban_string(struct sess *sp, const char *str)
+VRT_ban_string(const struct req *req, const char *str)
 {
 	char *a1, *a2, *a3;
 	char **av;
@@ -458,7 +459,7 @@ VRT_ban_string(struct sess *sp, const char *str)
 	int good;
 	int i;
 
-	(void)sp;
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	av = VAV_Parse(str, NULL, ARGV_NOESC);
 	if (av[0] != NULL) {
 		/* XXX: report error how ? */
@@ -500,12 +501,14 @@ VRT_ban_string(struct sess *sp, const char *str)
  */
 
 void
-VRT_purge(const struct sess *sp, double ttl, double grace)
+VRT_purge(struct req *req, double ttl, double grace)
 {
-	if (sp->req->cur_method == VCL_MET_HIT)
-		HSH_Purge(sp, sp->req->obj->objcore->objhead, ttl, grace);
-	else if (sp->req->cur_method == VCL_MET_MISS)
-		HSH_Purge(sp, sp->req->objcore->objhead, ttl, grace);
+
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	if (req->cur_method == VCL_MET_HIT)
+		HSH_Purge(req, req->obj->objcore->objhead, ttl, grace);
+	else if (req->cur_method == VCL_MET_MISS)
+		HSH_Purge(req, req->objcore->objhead, ttl, grace);
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt
index 1569271..5ddd6ce 100644
--- a/bin/varnishd/flint.lnt
+++ b/bin/varnishd/flint.lnt
@@ -155,6 +155,16 @@
 
 -e441	//  for clause irregularity: loop variable '___' not found in 2nd for expression
 
+// Vmod instantiation symbols are defined in all vmods
+
+-esym(14, Vmod_Name)
+-esym(14, Vmod_Func)
+-esym(14, Vmod_Len)
+-esym(14, Vmod_Proto)
+-esym(14, Vmod_Spec)
+-esym(14, Vmod_Varnish_ABI)
+-esym(14, Vmod_Id)
+
 // Review all below this line ///////////////////////////////////////////////
 
 -e732   // 183 Loss of sign (___) (___ to ___)
diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h
index 7eb1b14..fe0fb9f 100644
--- a/bin/varnishd/hash/hash_slinger.h
+++ b/bin/varnishd/hash/hash_slinger.h
@@ -59,7 +59,7 @@ void HSH_Drop(struct worker *, struct object **);
 void HSH_Init(const struct hash_slinger *slinger);
 void HSH_AddString(struct req *, const char *str);
 void HSH_Insert(struct worker *, const void *hash, struct objcore *);
-void HSH_Purge(const struct sess *, struct objhead *, double ttl, double grace);
+void HSH_Purge(struct req *, struct objhead *, double ttl, double grace);
 void HSH_config(const char *h_arg);
 struct objcore *HSH_NewObjCore(struct worker *wrk);
 
diff --git a/bin/varnishtest/tests/c00033.vtc b/bin/varnishtest/tests/c00033.vtc
index d93a6d0..d4289e3 100644
--- a/bin/varnishtest/tests/c00033.vtc
+++ b/bin/varnishtest/tests/c00033.vtc
@@ -25,13 +25,13 @@ varnish v1 -vcl+backend {
 
 	sub vcl_hit {
 		if (req.request == "PURGE") {
-			C{ VRT_purge(sp, 0, 0); }C
+			C{ VRT_purge(req, 0, 0); }C
 			error 456 "got it";
 		}
 	}
 	sub vcl_miss {
 		if (req.request == "PURGE") {
-			C{ VRT_purge(sp, 0, 0); }C
+			C{ VRT_purge(req, 0, 0); }C
 			error 456 "got it";
 		}
 	}
diff --git a/include/vrt.h b/include/vrt.h
index 834f972..20545fc 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -31,7 +31,6 @@
  * XXX: When this file is changed, lib/libvcl/generate.py *MUST* be rerun.
  */
 
-struct sess;
 struct req;
 struct vsb;
 struct cli;
@@ -150,9 +149,9 @@ int VRT_re_match(struct req *, const char *, void *re);
 const char *VRT_regsub(struct req *, int all, const char *,
     void *, const char *);
 
-void VRT_ban(struct sess *sp, char *, ...);
-void VRT_ban_string(struct sess *sp, const char *);
-void VRT_purge(const struct sess *sp, double ttl, double grace);
+void VRT_ban(const struct req *, char *, ...);
+void VRT_ban_string(const struct req *, const char *);
+void VRT_purge(struct req *, double ttl, double grace);
 
 void VRT_count(struct req *, unsigned);
 int VRT_rewrite(const char *, const char *);
@@ -171,11 +170,10 @@ void VRT_hashdata(struct req *, const char *str, ...);
 int VRT_strcmp(const char *s1, const char *s2);
 void VRT_memmove(void *dst, const void *src, unsigned len);
 
-void VRT_ESI(const struct sess *sp);
-void VRT_Rollback(const struct sess *sp);
+void VRT_Rollback(struct req *);
 
 /* Synthetic pages */
-void VRT_synth_page(struct req *sp, unsigned flags, const char *, ...);
+void VRT_synth_page(const struct req *, unsigned flags, const char *, ...);
 
 /* Backend related */
 void VRT_init_dir(struct cli *, struct director **, const char *name,
@@ -209,10 +207,10 @@ int VRT_Stv(const char *nm);
 
 /* Convert things to string */
 
-char *VRT_IP_string(struct req *, const struct sockaddr_storage *sa);
-char *VRT_int_string(struct req *, int);
-char *VRT_double_string(struct req *, double);
-char *VRT_time_string(struct req *, double);
+char *VRT_IP_string(const struct req *, const struct sockaddr_storage *sa);
+char *VRT_int_string(const struct req *, int);
+char *VRT_double_string(const struct req *, double);
+char *VRT_time_string(const struct req *, double);
 const char *VRT_bool_string(const struct req *, unsigned);
 const char *VRT_backend_string(const struct req *, const struct director *d);
 
diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py
index 0c1c02e..c999186 100755
--- a/lib/libvcl/generate.py
+++ b/lib/libvcl/generate.py
@@ -721,7 +721,7 @@ struct cli;
 
 typedef int vcl_init_f(struct cli *);
 typedef void vcl_fini_f(struct cli *);
-typedef int vcl_func_f(struct sess *sp, struct req *req);
+typedef int vcl_func_f(struct req *req);
 """)
 
 
diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c
index 81cf597..7eecc33 100644
--- a/lib/libvcl/vcc_action.c
+++ b/lib/libvcl/vcc_action.c
@@ -44,7 +44,7 @@ parse_call(struct vcc *tl)
 	ExpectErr(tl, ID);
 	vcc_AddCall(tl, tl->t);
 	vcc_AddRef(tl, tl->t, SYM_SUB);
-	Fb(tl, 1, "if (VGC_function_%.*s(sp, req))\n", PF(tl->t));
+	Fb(tl, 1, "if (VGC_function_%.*s(req))\n", PF(tl->t));
 	Fb(tl, 1, "\treturn (1);\n");
 	vcc_NextToken(tl);
 	return;
@@ -178,7 +178,7 @@ parse_ban(struct vcc *tl)
 	ExpectErr(tl, '(');
 	vcc_NextToken(tl);
 
-	Fb(tl, 1, "VRT_ban_string(sp, ");
+	Fb(tl, 1, "VRT_ban_string(req, ");
 	vcc_Expr(tl, STRING);
 	ERRCHK(tl);
 	Fb(tl, 0, ");\n");
@@ -197,7 +197,7 @@ parse_ban_url(struct vcc *tl)
 	ExpectErr(tl, '(');
 	vcc_NextToken(tl);
 
-	Fb(tl, 1, "VRT_ban(sp, \"req.url\", \"~\", ");
+	Fb(tl, 1, "VRT_ban(req, \"req.url\", \"~\", ");
 	vcc_Expr(tl, STRING);
 	ERRCHK(tl);
 	ExpectErr(tl, ')');
@@ -270,7 +270,7 @@ parse_rollback(struct vcc *tl)
 {
 
 	vcc_NextToken(tl);
-	Fb(tl, 1, "VRT_Rollback(sp);\n");
+	Fb(tl, 1, "VRT_Rollback(req);\n");
 }
 
 /*--------------------------------------------------------------------*/
@@ -280,7 +280,7 @@ parse_purge(struct vcc *tl)
 {
 
 	vcc_NextToken(tl);
-	Fb(tl, 1, "VRT_purge(sp, 0, 0);\n");
+	Fb(tl, 1, "VRT_purge(req, 0, 0);\n");
 }
 
 /*--------------------------------------------------------------------*/
diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c
index a16fbed..30f2a24 100644
--- a/lib/libvcl/vcc_compile.c
+++ b/lib/libvcl/vcc_compile.c
@@ -672,7 +672,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 __match_proto__(vcl_func_f)\n");
-		Fc(tl, 1, "VGC_function_%s(struct sess *sp, struct req *req)\n",
+		Fc(tl, 1, "VGC_function_%s(struct req *req)\n",
 		    method_tab[i].name);
 		AZ(VSB_finish(tl->fm[i]));
 		Fc(tl, 1, "{\n");
diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c
index a3ef4b6..8fbaa04 100644
--- a/lib/libvcl/vcc_expr.c
+++ b/lib/libvcl/vcc_expr.c
@@ -539,7 +539,7 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym)
 	SkipToken(tl, ID);
 	SkipToken(tl, '(');
 	p = sym->args;
-	e2 = vcc_mk_expr(vcc_arg_type(&p), "%s(sp\v+", sym->cfunc);
+	e2 = vcc_mk_expr(vcc_arg_type(&p), "%s(req\v+", sym->cfunc);
 	while (*p != '\0') {
 		e1 = NULL;
 		fmt = vcc_arg_type(&p);
diff --git a/lib/libvcl/vcc_parse.c b/lib/libvcl/vcc_parse.c
index 1a6bbf3..10170b3 100644
--- a/lib/libvcl/vcc_parse.c
+++ b/lib/libvcl/vcc_parse.c
@@ -225,11 +225,9 @@ vcc_Function(struct vcc *tl)
 		}
 		tl->curproc = vcc_AddProc(tl, tl->t);
 		Fh(tl, 0, "static int VGC_function_%.*s "
-		    "(struct sess *, struct req *);\n",
-		    PF(tl->t));
+		    "(struct req *);\n", PF(tl->t));
 		Fc(tl, 1, "\nstatic int __match_proto__(vcl_func_t)\n");
-		Fc(tl, 1, "VGC_function_%.*s"
-		    "(struct sess *sp, struct req *req)\n",
+		Fc(tl, 1, "VGC_function_%.*s(struct req *req)\n",
 		    PF(tl->t));
 	}
 	vcc_NextToken(tl);
diff --git a/lib/libvcl/vmodtool.py b/lib/libvcl/vmodtool.py
index 041edcb..e2cf8b5 100755
--- a/lib/libvcl/vmodtool.py
+++ b/lib/libvcl/vmodtool.py
@@ -81,7 +81,7 @@ def do_func(fname, rval, args, vargs):
 	#print(fname, rval, args)
 
 	# C argument list
-	cargs = "(struct sess *"
+	cargs = "(struct req *"
 	for i in args:
 		cargs += ", " + i
 	cargs += ")"
@@ -273,7 +273,7 @@ fh = open("vcc_if.h", "w")
 file_header(fc)
 file_header(fh)
 
-fh.write('struct sess;\n')
+fh.write('struct req;\n')
 fh.write('struct VCL_conf;\n')
 fh.write('struct vmod_priv;\n')
 fh.write("\n");
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 309664a..fd65fd2 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -35,24 +35,24 @@
 #include "vrt.h"
 #include "vcc_if.h"
 
-void
-vmod_panic(struct sess *sp, const char *str, ...)
+void __match_proto__(td_debug_panic)
+vmod_panic(struct req *req, const char *str, ...)
 {
 	va_list ap;
 	char *b;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	va_start(ap, str);
-	b = VRT_String(sp->req->http->ws, "PANIC: ", str, ap);
+	b = VRT_String(req->http->ws, "PANIC: ", str, ap);
 	va_end(ap);
 	VAS_Fail("VCL", "", 0, b, 0, 2);
 }
 
-const char * __match_proto__()
-vmod_author(struct sess *sp, const char *id)
+const char * __match_proto__(td_debug_author)
+vmod_author(struct req *req, const char *id)
 {
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	if (!strcmp(id, "phk"))
 		return ("Poul-Henning");
 	if (!strcmp(id, "des"))
@@ -74,11 +74,11 @@ init_function(struct vmod_priv *priv, const struct VCL_conf *cfg)
 	return (0);
 }
 
-void
-vmod_test_priv_call(struct sess *sp, struct vmod_priv *priv)
+void __match_proto__(td_debug_test_priv_call)
+vmod_test_priv_call(struct req *req, struct vmod_priv *priv)
 {
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	if (priv->priv == NULL) {
 		priv->priv = strdup("BAR");
 		priv->free = free;
@@ -87,11 +87,11 @@ vmod_test_priv_call(struct sess *sp, struct vmod_priv *priv)
 	}
 }
 
-void
-vmod_test_priv_vcl(struct sess *sp, struct vmod_priv *priv)
+void __match_proto__(td_debug_test_priv_vcl)
+vmod_test_priv_vcl(struct req *req, struct vmod_priv *priv)
 {
 
-        CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+        CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
         assert(!strcmp(priv->priv, "FOO"));
 }
 
diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index c8937f6..4265cf1 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -45,23 +45,25 @@
 
 #include "vcc_if.h"
 
-void __match_proto__()
-vmod_set_ip_tos(struct sess *sp, int tos)
+void __match_proto__(td_std_set_ip_tos)
+vmod_set_ip_tos(struct req *req, int tos)
 {
 
-	VTCP_Assert(setsockopt(sp->fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)));
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	VTCP_Assert(setsockopt(req->sp->fd,
+	    IPPROTO_IP, IP_TOS, &tos, sizeof(tos)));
 }
 
-static const char * __match_proto__()
-vmod_updown(struct sess *sp, int up, const char *s, va_list ap)
+static const char *
+vmod_updown(struct req *req, int up, const char *s, va_list ap)
 {
 	unsigned u;
 	char *b, *e;
 	const char *p;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	u = WS_Reserve(sp->req->ws, 0);
-	e = b = sp->req->ws->f;
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	u = WS_Reserve(req->ws, 0);
+	e = b = req->ws->f;
 	e += u;
 	p = s;
 	while (p != vrt_magic_string_end && b < e) {
@@ -78,101 +80,101 @@ vmod_updown(struct sess *sp, int up, const char *s, va_list ap)
 		*b = '\0';
 	b++;
 	if (b > e) {
-		WS_Release(sp->req->ws, 0);
+		WS_Release(req->ws, 0);
 		return (NULL);
 	} else {
 		e = b;
-		b = sp->req->ws->f;
-		WS_Release(sp->req->ws, e - b);
+		b = req->ws->f;
+		WS_Release(req->ws, e - b);
 		return (b);
 	}
 }
 
-const char * __match_proto__()
-vmod_toupper(struct sess *sp, const char *s, ...)
+const char * __match_proto__(td_std_toupper)
+vmod_toupper(struct req *req, const char *s, ...)
 {
 	const char *p;
 	va_list ap;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	va_start(ap, s);
-	p = vmod_updown(sp, 1, s, ap);
+	p = vmod_updown(req, 1, s, ap);
 	va_end(ap);
 	return (p);
 }
 
-const char * __match_proto__()
-vmod_tolower(struct sess *sp, const char *s, ...)
+const char * __match_proto__(td_std_tolower)
+vmod_tolower(struct req *req, const char *s, ...)
 {
 	const char *p;
 	va_list ap;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	va_start(ap, s);
-	p = vmod_updown(sp, 0, s, ap);
+	p = vmod_updown(req, 0, s, ap);
 	va_end(ap);
 	return (p);
 }
 
-double
-vmod_random(struct sess *sp, double lo, double hi)
+double __match_proto__(td_std_random)
+vmod_random(struct req *req, double lo, double hi)
 {
 	double a;
 
-	(void)sp;
-
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	a = drand48();
 	a *= hi - lo;
 	a += lo;
 	return (a);
 }
 
-void __match_proto__()
-vmod_log(struct sess *sp, const char *fmt, ...)
+void __match_proto__(td_std_log)
+vmod_log(struct req *req, const char *fmt, ...)
 {
 	unsigned u;
 	va_list ap;
 	txt t;
 
-	u = WS_Reserve(sp->req->ws, 0);
-	t.b = sp->req->ws->f;
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	u = WS_Reserve(req->ws, 0);
+	t.b = req->ws->f;
 	va_start(ap, fmt);
 	t.e = VRT_StringList(t.b, u, fmt, ap);
 	va_end(ap);
 	if (t.e != NULL) {
 		assert(t.e > t.b);
 		t.e--;
-		VSLbt(sp->req->vsl, SLT_VCL_Log, t);
+		VSLbt(req->vsl, SLT_VCL_Log, t);
 	}
-	WS_Release(sp->req->ws, 0);
+	WS_Release(req->ws, 0);
 }
 
-void __match_proto__()
-vmod_syslog(struct sess *sp, int fac, const char *fmt, ...)
+void __match_proto__(td_std_syslog)
+vmod_syslog(struct req *req, int fac, const char *fmt, ...)
 {
 	char *p;
 	unsigned u;
 	va_list ap;
 
-	u = WS_Reserve(sp->req->ws, 0);
-	p = sp->req->ws->f;
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	u = WS_Reserve(req->ws, 0);
+	p = req->ws->f;
 	va_start(ap, fmt);
 	p = VRT_StringList(p, u, fmt, ap);
 	va_end(ap);
 	if (p != NULL)
 		syslog(fac, "%s", p);
-	WS_Release(sp->req->ws, 0);
+	WS_Release(req->ws, 0);
 }
 
-void __match_proto__()
-vmod_collect(struct sess *sp, enum gethdr_e e, const char *h)
+void __match_proto__(td_std_collect)
+vmod_collect(struct req *req, enum gethdr_e e, const char *h)
 {
-	(void)e;
-	(void)sp;
-	(void)h;
+
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	if (e == HDR_REQ)
-		http_CollectHdr(sp->req->http, h);
-	else if (e == HDR_BERESP && sp->req->busyobj != NULL)
-		http_CollectHdr(sp->req->busyobj->beresp, h);
+		http_CollectHdr(req->http, h);
+	else if (e == HDR_BERESP && req->busyobj != NULL)
+		http_CollectHdr(req->busyobj->beresp, h);
 }
 
diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c
index 149be81..45cc7a1 100644
--- a/lib/libvmod_std/vmod_std_conversions.c
+++ b/lib/libvmod_std/vmod_std_conversions.c
@@ -39,12 +39,12 @@
 #include "vcc_if.h"
 
 double __match_proto__()
-vmod_duration(struct sess *sp, const char *p, double d)
+vmod_duration(struct req *req, const char *p, double d)
 {
 	char *e;
 	double r;
 
-	(void)sp;
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 
 	if (p == NULL)
 		return (d);
@@ -89,12 +89,12 @@ vmod_duration(struct sess *sp, const char *p, double d)
 }
 
 int __match_proto__()
-vmod_integer(struct sess *sp, const char *p, int i)
+vmod_integer(struct req *req, const char *p, int i)
 {
 	char *e;
 	int r;
 
-	(void)sp;
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 
 	if (p == NULL)
 		return (i);
diff --git a/lib/libvmod_std/vmod_std_fileread.c b/lib/libvmod_std/vmod_std_fileread.c
index 7012b66..d424d75 100644
--- a/lib/libvmod_std/vmod_std_fileread.c
+++ b/lib/libvmod_std/vmod_std_fileread.c
@@ -82,13 +82,13 @@ free_frfile(void *ptr)
 	}
 }
 
-const char *
-vmod_fileread(struct sess *sp, struct vmod_priv *priv, const char *file_name)
+const char * __match_proto__(td_std_fileread)
+vmod_fileread(struct req *req, struct vmod_priv *priv, const char *file_name)
 {
 	struct frfile *frf = NULL;
 	char *s;
 
-	(void)sp;
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	AN(priv);
 
 	if (priv->priv != NULL) {



More information about the varnish-commit mailing list