[master] acab05e More VRT sp->req movements

Poul-Henning Kamp phk at varnish-cache.org
Mon Jun 18 11:13:41 CEST 2012


commit acab05e046bad0f194a699d229b981ee8d5ffecc
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jun 18 09:13:27 2012 +0000

    More VRT sp->req movements

diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 5675311..d227949 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -83,10 +83,10 @@ VRT_count(struct req *req, unsigned u)
 /*--------------------------------------------------------------------*/
 
 void
-VRT_acl_log(const struct sess *sp, const char *msg)
+VRT_acl_log(struct req *req, const char *msg)
 {
 
-	VSLb(sp->req->vsl, SLT_VCL_acl, "%s", msg);
+	VSLb(req->vsl, SLT_VCL_acl, "%s", msg);
 }
 
 /*--------------------------------------------------------------------*/
@@ -385,13 +385,14 @@ VRT_Rollback(const struct sess *sp)
 /*--------------------------------------------------------------------*/
 
 void
-VRT_panic(const struct sess *sp, const char *str, ...)
+VRT_panic(struct req *req, const char *str, ...)
 {
 	va_list ap;
 	char *b;
 
+	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);
 }
diff --git a/bin/varnishd/cache/cache_vrt_re.c b/bin/varnishd/cache/cache_vrt_re.c
index 765cd27..e4b9750 100644
--- a/bin/varnishd/cache/cache_vrt_re.c
+++ b/bin/varnishd/cache/cache_vrt_re.c
@@ -62,11 +62,12 @@ VRT_re_fini(void *rep)
 }
 
 int
-VRT_re_match(const struct sess *sp, const char *s, void *re)
+VRT_re_match(struct req *req, const char *s, void *re)
 {
 	vre_t *t;
 	int i;
 
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	if (s == NULL)
 		s = "";
 	AN(re);
@@ -75,13 +76,12 @@ VRT_re_match(const struct sess *sp, const char *s, void *re)
 	if (i >= 0)
 		return (1);
 	if (i < VRE_ERROR_NOMATCH )
-		VSLb(sp->req->vsl, SLT_VCL_Error,
-		    "Regexp matching returned %d", i);
+		VSLb(req->vsl, SLT_VCL_Error, "Regexp matching returned %d", i);
 	return (0);
 }
 
 const char *
-VRT_regsub(const struct sess *sp, int all, const char *str, void *re,
+VRT_regsub(struct req *req, int all, const char *str, void *re,
     const char *sub)
 {
 	int ovector[30];
@@ -94,6 +94,7 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re,
 	int options = 0;
 	size_t len;
 
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	AN(re);
 	if (str == NULL)
 		str = "";
@@ -109,13 +110,12 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re,
 	if (i == VRE_ERROR_NOMATCH)
 		return(str);
 	if (i < VRE_ERROR_NOMATCH ) {
-		VSLb(sp->req->vsl, SLT_VCL_Error,
-		    "Regexp matching returned %d", i);
+		VSLb(req->vsl, SLT_VCL_Error, "Regexp matching returned %d", i);
 		return(str);
 	}
 
-	u = WS_Reserve(sp->req->http->ws, 0);
-	res.e = res.b = b0 = sp->req->http->ws->f;
+	u = WS_Reserve(req->http->ws, 0);
+	res.e = res.b = b0 = req->http->ws->f;
 	res.e += u;
 
 	do {
@@ -147,8 +147,8 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re,
 		i = VRE_exec(t, str, len, 0, options, ovector, 30,
 		    &cache_param->vre_limits);
 		if (i < VRE_ERROR_NOMATCH ) {
-			WS_Release(sp->req->http->ws, 0);
-			VSLb(sp->req->vsl, SLT_VCL_Error,
+			WS_Release(req->http->ws, 0);
+			VSLb(req->vsl, SLT_VCL_Error,
 			    "Regexp matching returned %d", i);
 			return(str);
 		}
@@ -157,10 +157,10 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re,
 	/* Copy suffix to match */
 	Tadd(&res, str, len+1);
 	if (res.b >= res.e) {
-		WS_Release(sp->req->http->ws, 0);
+		WS_Release(req->http->ws, 0);
 		return (str);
 	}
 	Tcheck(res);
-	WS_ReleaseP(sp->req->http->ws, res.b);
+	WS_ReleaseP(req->http->ws, res.b);
 	return (b0);
 }
diff --git a/include/vrt.h b/include/vrt.h
index a6a2642..50d4d8b 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -141,16 +141,16 @@ struct vrt_ref {
 /* ACL related */
 #define VRT_ACL_MAXADDR		16	/* max(IPv4, IPv6) */
 
-void VRT_acl_log(const struct sess *, const char *msg);
+void VRT_acl_log(struct req *, const char *msg);
 
 /* Regexp related */
 void VRT_re_init(void **, const char *);
 void VRT_re_fini(void *);
-int VRT_re_match(const struct sess *sp, const char *, void *re);
-const char *VRT_regsub(const struct sess *sp, int all, const char *,
+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_panic(const struct sess *sp, const char *, ...);
+void VRT_panic(struct req *req, 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);
diff --git a/lib/libvcl/vcc_acl.c b/lib/libvcl/vcc_acl.c
index 9535f59..3e037ec 100644
--- a/lib/libvcl/vcc_acl.c
+++ b/lib/libvcl/vcc_acl.c
@@ -357,7 +357,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon)
 	const char *oc;
 
 	Fh(tl, 0, "\nstatic int\n");
-	Fh(tl, 0, "match_acl_%s_%s(const struct sess *sp, const void *p)\n",
+	Fh(tl, 0, "match_acl_%s_%s(struct req *req, const void *p)\n",
 	    anon ? "anon" : "named", acln);
 	Fh(tl, 0, "{\n");
 	Fh(tl, 0, "\tconst unsigned char *a;\n");
@@ -372,7 +372,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon)
 	Fh(tl, 0, "\telse if (fam == %d)\n", PF_INET6);
 	Fh(tl, 0, "\t\ta += %zd;\n", offsetof(struct sockaddr_in6, sin6_addr));
 	Fh(tl, 0, "\telse {\n");
-	Fh(tl, 0, "\t\tVRT_acl_log(sp, \"NO_FAM %s\");\n", acln);
+	Fh(tl, 0, "\t\tVRT_acl_log(req, \"NO_FAM %s\");\n", acln);
 	Fh(tl, 0, "\t\treturn(0);\n");
 	Fh(tl, 0, "\t}\n\n");
 	depth = -1;
@@ -424,7 +424,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon)
 		i = (ae->mask + 7) / 8;
 
 		if (!anon) {
-			Fh(tl, 0, "\t%*sVRT_acl_log(sp, \"%sMATCH %s \" ",
+			Fh(tl, 0, "\t%*sVRT_acl_log(req, \"%sMATCH %s \" ",
 			    -i, "", ae->not ? "NEG_" : "", acln);
 			EncToken(tl->fh, ae->t_addr);
 			if (ae->t_mask != NULL)
@@ -441,7 +441,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon)
 
 	/* Deny by default */
 	if (!anon)
-		Fh(tl, 0, "\tVRT_acl_log(sp, \"NO_MATCH %s\");\n", acln);
+		Fh(tl, 0, "\tVRT_acl_log(req, \"NO_MATCH %s\");\n", acln);
 	Fh(tl, 0, "\treturn (0);\n}\n");
 }
 
@@ -457,7 +457,7 @@ vcc_Acl_Hack(struct vcc *tl, char *b)
 	bprintf(acln, "%u", tl->unique++);
 	vcc_acl_entry(tl);
 	vcc_acl_emit(tl, acln, 1);
-	sprintf(b, "%smatch_acl_anon_%s(sp, \v1)",
+	sprintf(b, "%smatch_acl_anon_%s(req, \v1)",
 	    (tcond == T_NEQ ? "!" : ""), acln);
 }
 
diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c
index 31b2bad..d60b885 100644
--- a/lib/libvcl/vcc_action.c
+++ b/lib/libvcl/vcc_action.c
@@ -238,7 +238,7 @@ parse_panic(struct vcc *tl)
 {
 	vcc_NextToken(tl);
 
-	Fb(tl, 1, "VRT_panic(sp, ");
+	Fb(tl, 1, "VRT_panic(req, ");
 	vcc_Expr(tl, STRING);
 	ERRCHK(tl);
 	Fb(tl, 0, ", vrt_magic_string_end);\n");
diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c
index d964ff1..a3ef4b6 100644
--- a/lib/libvcl/vcc_expr.c
+++ b/lib/libvcl/vcc_expr.c
@@ -466,7 +466,7 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, const struct symbol *sym)
 	p = vcc_regexp(tl);
 	vcc_NextToken(tl);
 
-	bprintf(buf, "VRT_regsub(sp, %d,\n\v1,\n%s\n", all, p);
+	bprintf(buf, "VRT_regsub(req, %d,\n\v1,\n%s\n", all, p);
 	*e = vcc_expr_edit(STRING, buf, e2, *e);
 
 	SkipToken(tl, ',');
@@ -947,7 +947,7 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, enum var_type fmt)
 		re = vcc_regexp(tl);
 		ERRCHK(tl);
 		vcc_NextToken(tl);
-		bprintf(buf, "%sVRT_re_match(sp, \v1, %s)", not, re);
+		bprintf(buf, "%sVRT_re_match(req, \v1, %s)", not, re);
 		*e = vcc_expr_edit(BOOL, buf, *e, NULL);
 		return;
 	}
@@ -957,7 +957,8 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, enum var_type fmt)
 		vcc_NextToken(tl);
 		ExpectErr(tl, ID);
 		vcc_AddRef(tl, tl->t, SYM_ACL);
-		bprintf(buf, "%smatch_acl_named_%.*s(sp, \v1)", not, PF(tl->t));
+		bprintf(buf, "%smatch_acl_named_%.*s(req, \v1)",
+		    not, PF(tl->t));
 		vcc_NextToken(tl);
 		*e = vcc_expr_edit(BOOL, buf, *e, NULL);
 		return;



More information about the varnish-commit mailing list