[master] b4d76fe Move more of the VRT interface from 'sp' to 'req'

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


commit b4d76fea32541ffa008e6187faa1ffd21919a5e5
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jun 18 08:31:14 2012 +0000

    Move more of the VRT interface from 'sp' to 'req'

diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 79efc69..d288e3d 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -156,20 +156,21 @@ HSH_DeleteObjHead(struct dstat *ds, struct objhead *oh)
 }
 
 void
-HSH_AddString(const struct sess *sp, const char *str)
+HSH_AddString(struct req *req, const char *str)
 {
 	int l;
 
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	if (str == NULL)
 		str = "";
 	l = strlen(str);
 
-	AN(sp->req->sha256ctx);
-	SHA256_Update(sp->req->sha256ctx, str, l);
-	SHA256_Update(sp->req->sha256ctx, "#", 1);
+	AN(req->sha256ctx);
+	SHA256_Update(req->sha256ctx, str, l);
+	SHA256_Update(req->sha256ctx, "#", 1);
 
 	if (cache_param->log_hash)
-		VSLb(sp->req->vsl, SLT_Hash, "%s", str);
+		VSLb(req->vsl, SLT_Hash, "%s", str);
 }
 
 /*---------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 524a9b2..f1b1f3c 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -93,27 +93,27 @@ VRT_acl_log(const struct sess *sp, const char *msg)
 /*--------------------------------------------------------------------*/
 
 static struct http *
-vrt_selecthttp(const struct sess *sp, enum gethdr_e where)
+vrt_selecthttp(const struct req *req, enum gethdr_e where)
 {
 	struct http *hp;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	switch (where) {
 	case HDR_REQ:
-		hp = sp->req->http;
+		hp = req->http;
 		break;
 	case HDR_BEREQ:
-		hp = sp->req->busyobj->bereq;
+		hp = req->busyobj->bereq;
 		break;
 	case HDR_BERESP:
-		hp = sp->req->busyobj->beresp;
+		hp = req->busyobj->beresp;
 		break;
 	case HDR_RESP:
-		hp = sp->req->resp;
+		hp = req->resp;
 		break;
 	case HDR_OBJ:
-		CHECK_OBJ_NOTNULL(sp->req->obj, OBJECT_MAGIC);
-		hp = sp->req->obj->http;
+		CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);
+		hp = req->obj->http;
 		break;
 	default:
 		INCOMPL();
@@ -123,13 +123,13 @@ vrt_selecthttp(const struct sess *sp, enum gethdr_e where)
 }
 
 char *
-VRT_GetHdr(const struct sess *sp, enum gethdr_e where, const char *n)
+VRT_GetHdr(const struct req *req, enum gethdr_e where, const char *n)
 {
 	char *p;
 	struct http *hp;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	hp = vrt_selecthttp(sp, where);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	hp = vrt_selecthttp(req, where);
 	if (!http_GetHdr(hp, n, &p))
 		return (NULL);
 	return (p);
@@ -215,22 +215,22 @@ VRT_WrkString(const struct sess *sp, const char *p, ...)
 /*--------------------------------------------------------------------*/
 
 void
-VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr,
+VRT_SetHdr(struct req *req , enum gethdr_e where, const char *hdr,
     const char *p, ...)
 {
 	struct http *hp;
 	va_list ap;
 	char *b;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	hp = vrt_selecthttp(sp, where);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	hp = vrt_selecthttp(req, where);
 	va_start(ap, p);
 	if (p == NULL) {
 		http_Unset(hp, hdr);
 	} else {
 		b = VRT_String(hp->ws, hdr + 1, p, ap);
 		if (b == NULL) {
-			VSLb(sp->req->vsl, SLT_LostHeader, "%s", hdr + 1);
+			VSLb(req->vsl, SLT_LostHeader, "%s", hdr + 1);
 		} else {
 			http_Unset(hp, hdr);
 			http_SetHeader(hp, b);
@@ -242,16 +242,16 @@ VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr,
 /*--------------------------------------------------------------------*/
 
 void
-VRT_handling(const struct sess *sp, unsigned hand)
+VRT_handling(struct req *req, unsigned hand)
 {
 
-	if (sp == NULL) {
+	if (req == NULL) {
 		assert(hand == VCL_RET_OK);
 		return;
 	}
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	assert(hand < VCL_RET_MAX);
-	sp->req->handling = hand;
+	req->handling = hand;
 }
 
 /*--------------------------------------------------------------------
@@ -259,18 +259,18 @@ VRT_handling(const struct sess *sp, unsigned hand)
  */
 
 void
-VRT_hashdata(const struct sess *sp, const char *str, ...)
+VRT_hashdata(struct req *req, const char *str, ...)
 {
 	va_list ap;
 	const char *p;
 
-	HSH_AddString(sp, str);
+	HSH_AddString(req, str);
 	va_start(ap, str);
 	while (1) {
 		p = va_arg(ap, const char *);
 		if (p == vrt_magic_string_end)
 			break;
-		HSH_AddString(sp, p);
+		HSH_AddString(req, p);
 	}
 }
 
diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h
index cbf62ba..7eb1b14 100644
--- a/bin/varnishd/hash/hash_slinger.h
+++ b/bin/varnishd/hash/hash_slinger.h
@@ -29,6 +29,7 @@
  */
 
 struct sess;
+struct req;
 struct worker;
 struct object;
 
@@ -56,7 +57,7 @@ struct objcore *HSH_Lookup(struct sess *sp);
 void HSH_Ref(struct objcore *o);
 void HSH_Drop(struct worker *, struct object **);
 void HSH_Init(const struct hash_slinger *slinger);
-void HSH_AddString(const struct sess *sp, const char *str);
+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_config(const char *h_arg);
diff --git a/include/vrt.h b/include/vrt.h
index 0b122ec..dc5ba13 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -161,12 +161,12 @@ void VRT_error(const struct sess *, unsigned, const char *);
 int VRT_switch_config(const char *);
 
 enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ, HDR_BERESP };
-char *VRT_GetHdr(const struct sess *, enum gethdr_e where, const char *);
-void VRT_SetHdr(const struct sess *, enum gethdr_e where, const char *,
+char *VRT_GetHdr(const struct req *, enum gethdr_e where, const char *);
+void VRT_SetHdr(struct req *, enum gethdr_e where, const char *,
     const char *, ...);
-void VRT_handling(const struct sess *sp, unsigned hand);
+void VRT_handling(struct req *, unsigned hand);
 
-void VRT_hashdata(const struct sess *sp, const char *str, ...);
+void VRT_hashdata(struct req *, const char *str, ...);
 
 /* Simple stuff */
 int VRT_strcmp(const char *s1, const char *s2);
@@ -217,9 +217,9 @@ char *VRT_time_string(const struct sess *sp, double);
 const char *VRT_bool_string(const struct sess *sp, unsigned);
 const char *VRT_backend_string(const struct sess *sp, const struct director *d);
 
-#define VRT_done(sp, hand)			\
+#define VRT_done(req, hand)			\
 	do {					\
-		VRT_handling(sp, hand);		\
+		VRT_handling(req, hand);	\
 		return (1);			\
 	} while (0)
 
diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c
index e725c6d..31a940b 100644
--- a/lib/libvcl/vcc_action.c
+++ b/lib/libvcl/vcc_action.c
@@ -77,7 +77,7 @@ parse_error(struct vcc *tl)
 			Fb(tl, 1, ", 0\n");
 	}
 	Fb(tl, 1, ");\n");
-	Fb(tl, 1, "VRT_done(sp, VCL_RET_ERROR);\n");
+	Fb(tl, 1, "VRT_done(req, VCL_RET_ERROR);\n");
 }
 
 /*--------------------------------------------------------------------*/
@@ -224,7 +224,7 @@ parse_hash_data(struct vcc *tl)
 	vcc_NextToken(tl);
 	SkipToken(tl, '(');
 
-	Fb(tl, 1, "VRT_hashdata(sp, ");
+	Fb(tl, 1, "VRT_hashdata(req, ");
 	vcc_Expr(tl, STRING_LIST);
 	ERRCHK(tl);
 	Fb(tl, 0, ");\n");
@@ -259,7 +259,7 @@ parse_return(struct vcc *tl)
 #define VCL_RET_MAC(l, U, B)						\
 	do {								\
 		if (vcc_IdIs(tl->t, #l)) {				\
-			Fb(tl, 1, "VRT_done(sp, VCL_RET_" #U ");\n");	\
+			Fb(tl, 1, "VRT_done(req, VCL_RET_" #U ");\n");	\
 			vcc_ProcAction(tl->curproc, VCL_RET_##U, tl->t);\
 			retval = 1;					\
 		}							\
diff --git a/lib/libvcl/vcc_var.c b/lib/libvcl/vcc_var.c
index 1bbac15..aa728e6 100644
--- a/lib/libvcl/vcc_var.c
+++ b/lib/libvcl/vcc_var.c
@@ -59,10 +59,10 @@ vcc_Var_Wildcard(struct vcc *tl, const struct token *t, const struct symbol *wc)
 
 	bprintf(buf, "\\%03o%s:", (unsigned)l, v->name + vh->len);
 	v->hdr = TlDup(tl, buf);
-	bprintf(buf, "VRT_GetHdr(sp, %s, \"%s\")", v->http, v->hdr);
+	bprintf(buf, "VRT_GetHdr(req, %s, \"%s\")", v->http, v->hdr);
 	v->rname = TlDup(tl, buf);
 
-	bprintf(buf, "VRT_SetHdr(sp, %s, \"%s\", ", v->http, v->hdr);
+	bprintf(buf, "VRT_SetHdr(req, %s, \"%s\", ", v->http, v->hdr);
 	v->lname = TlDup(tl, buf);
 
 	sym = VCC_AddSymbolTok(tl, t, SYM_VAR);



More information about the varnish-commit mailing list