[master] 30ecc41 Downgrade all the VRT-var functions from sp to req

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


commit 30ecc418275ca0aacfd47b91a2b4c8eef5960df8
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jun 14 14:26:52 2012 +0000

    Downgrade all the VRT-var functions from sp to req

diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index a7d68ad..524a9b2 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -277,10 +277,10 @@ VRT_hashdata(const struct sess *sp, const char *str, ...)
 /*--------------------------------------------------------------------*/
 
 double
-VRT_r_now(const struct sess *sp)
+VRT_r_now(const struct req *req)
 {
 
-	(void)sp;
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	return (VTIM_real());
 }
 
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 7a88447..8d325ca 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -63,59 +63,60 @@ vrt_do_string(const struct http *hp, int fld,
 
 #define VRT_DO_HDR(obj, hdr, http, fld)				\
 void								\
-VRT_l_##obj##_##hdr(const struct sess *sp, const char *p, ...)	\
+VRT_l_##obj##_##hdr(const struct req *req, const char *p, ...)	\
 {								\
 	va_list ap;						\
 								\
-	(void)sp;						\
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);			\
 	va_start(ap, p);					\
 	vrt_do_string(http, fld, #obj "." #hdr, p, ap);		\
 	va_end(ap);						\
 }								\
 								\
 const char *							\
-VRT_r_##obj##_##hdr(const struct sess *sp)			\
+VRT_r_##obj##_##hdr(const struct req *req)			\
 {								\
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);			\
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);			\
 	CHECK_OBJ_NOTNULL(http, HTTP_MAGIC);			\
 	return (http->hd[fld].b);				\
 }
 
-VRT_DO_HDR(req,   request,	sp->req->http,		HTTP_HDR_REQ)
-VRT_DO_HDR(req,   url,		sp->req->http,		HTTP_HDR_URL)
-VRT_DO_HDR(req,   proto,	sp->req->http,		HTTP_HDR_PROTO)
-VRT_DO_HDR(bereq, request,	sp->req->busyobj->bereq,	HTTP_HDR_REQ)
-VRT_DO_HDR(bereq, url,		sp->req->busyobj->bereq,	HTTP_HDR_URL)
-VRT_DO_HDR(bereq, proto,	sp->req->busyobj->bereq,	HTTP_HDR_PROTO)
-VRT_DO_HDR(obj,   proto,	sp->req->obj->http,	HTTP_HDR_PROTO)
-VRT_DO_HDR(obj,   response,	sp->req->obj->http,	HTTP_HDR_RESPONSE)
-VRT_DO_HDR(resp,  proto,	sp->req->resp,		HTTP_HDR_PROTO)
-VRT_DO_HDR(resp,  response,	sp->req->resp,		HTTP_HDR_RESPONSE)
-VRT_DO_HDR(beresp,  proto,	sp->req->busyobj->beresp,	HTTP_HDR_PROTO)
-VRT_DO_HDR(beresp,  response,	sp->req->busyobj->beresp, HTTP_HDR_RESPONSE)
+VRT_DO_HDR(req,   request,	req->http,		HTTP_HDR_REQ)
+VRT_DO_HDR(req,   url,		req->http,		HTTP_HDR_URL)
+VRT_DO_HDR(req,   proto,	req->http,		HTTP_HDR_PROTO)
+VRT_DO_HDR(bereq, request,	req->busyobj->bereq,	HTTP_HDR_REQ)
+VRT_DO_HDR(bereq, url,		req->busyobj->bereq,	HTTP_HDR_URL)
+VRT_DO_HDR(bereq, proto,	req->busyobj->bereq,	HTTP_HDR_PROTO)
+VRT_DO_HDR(obj,   proto,	req->obj->http,		HTTP_HDR_PROTO)
+VRT_DO_HDR(obj,   response,	req->obj->http,		HTTP_HDR_RESPONSE)
+VRT_DO_HDR(resp,  proto,	req->resp,		HTTP_HDR_PROTO)
+VRT_DO_HDR(resp,  response,	req->resp,		HTTP_HDR_RESPONSE)
+VRT_DO_HDR(beresp,  proto,	req->busyobj->beresp,	HTTP_HDR_PROTO)
+VRT_DO_HDR(beresp,  response,	req->busyobj->beresp,	HTTP_HDR_RESPONSE)
 
 /*--------------------------------------------------------------------*/
 
 #define VRT_DO_STATUS(obj, http)				\
 void								\
-VRT_l_##obj##_status(const struct sess *sp, int num)		\
+VRT_l_##obj##_status(const struct req *req, int num)		\
 {								\
 								\
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);			\
 	assert(num >= 100 && num <= 999);			\
 	http->status = (uint16_t)num;				\
 }								\
 								\
 int								\
-VRT_r_##obj##_status(const struct sess *sp)			\
+VRT_r_##obj##_status(const struct req *req)			\
 {								\
 								\
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);			\
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);			\
 	return(http->status);					\
 }
 
-VRT_DO_STATUS(obj, sp->req->obj->http)
-VRT_DO_STATUS(beresp, sp->req->busyobj->beresp)
-VRT_DO_STATUS(resp, sp->req->resp)
+VRT_DO_STATUS(obj, req->obj->http)
+VRT_DO_STATUS(beresp, req->busyobj->beresp)
+VRT_DO_STATUS(resp, req->resp)
 
 /*--------------------------------------------------------------------*/
 
@@ -125,25 +126,25 @@ VRT_DO_STATUS(resp, sp->req->resp)
  * is no object.
  */
 void
-VRT_l_beresp_saintmode(const struct sess *sp, double a)
+VRT_l_beresp_saintmode(const struct req *req, double a)
 {
 	struct trouble *new;
 	struct trouble *tr;
 	struct trouble *tr2;
 	struct vbc *vbc;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->req->busyobj, BUSYOBJ_MAGIC);
-	vbc = sp->req->busyobj->vbc;
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	CHECK_OBJ_NOTNULL(req->busyobj, BUSYOBJ_MAGIC);
+	vbc = req->busyobj->vbc;
 	if (!vbc)
 		return;
 	CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC);
 	if (!vbc->backend)
 		return;
 	CHECK_OBJ_NOTNULL(vbc->backend, BACKEND_MAGIC);
-	if (!sp->req->objcore->objhead)
+	if (!req->objcore->objhead)
 		return;
-	CHECK_OBJ_NOTNULL(sp->req->objcore, OBJCORE_MAGIC);
+	CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
 
 	/* Setting a negative holdoff period is a mistake. Detecting this
 	 * when compiling the VCL would be better.
@@ -152,8 +153,8 @@ VRT_l_beresp_saintmode(const struct sess *sp, double a)
 
 	ALLOC_OBJ(new, TROUBLE_MAGIC);
 	AN(new);
-	memcpy(new->digest, sp->req->digest, sizeof new->digest);
-	new->timeout = sp->req->t_req + a;
+	memcpy(new->digest, req->digest, sizeof new->digest);
+	new->timeout = req->t_req + a;
 
 	/* Insert the new item on the list before the first item with a
 	 * timeout at a later date (ie: sort by which entry will time out
@@ -181,17 +182,17 @@ VRT_l_beresp_saintmode(const struct sess *sp, double a)
 
 #define VBERESP(dir, type, onm, field)					\
 void									\
-VRT_l_##dir##_##onm(const struct sess *sp, type a)			\
+VRT_l_##dir##_##onm(const struct req *req, type a)			\
 {									\
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);				\
-	sp->req->field = a;						\
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);				\
+	req->field = a;							\
 }									\
 									\
 type									\
-VRT_r_##dir##_##onm(const struct sess *sp)				\
+VRT_r_##dir##_##onm(const struct req *req)				\
 {									\
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);				\
-	return (sp->req->field);					\
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);				\
+	return (req->field);						\
 }
 
 VBERESP(beresp, unsigned, do_esi, busyobj->do_esi)
@@ -203,46 +204,47 @@ VBERESP(beresp, unsigned, do_pass, busyobj->do_pass)
 /*--------------------------------------------------------------------*/
 
 const char *
-VRT_r_client_identity(const struct sess *sp)
+VRT_r_client_identity(struct req *req)
 {
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	if (sp->req->client_identity != NULL)
-		return (sp->req->client_identity);
+
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	if (req->client_identity != NULL)
+		return (req->client_identity);
 	else
-		return (sp->addr);
+		return (req->sp->addr);
 }
 
 void
-VRT_l_client_identity(const struct sess *sp, const char *str, ...)
+VRT_l_client_identity(struct req *req, const char *str, ...)
 {
 	va_list ap;
 	char *b;
 
 	va_start(ap, str);
-	b = VRT_String(sp->req->http->ws, NULL, str, ap);
+	b = VRT_String(req->http->ws, NULL, str, ap);
 	va_end(ap);
-	sp->req->client_identity = b;
+	req->client_identity = b;
 }
 
 /*--------------------------------------------------------------------*/
 
 #define BEREQ_TIMEOUT(which)					\
 void __match_proto__()						\
-VRT_l_bereq_##which(struct sess *sp, double num)		\
+VRT_l_bereq_##which(struct req *req, double num)		\
 {								\
 								\
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);			\
-	CHECK_OBJ_NOTNULL(sp->req->busyobj, BUSYOBJ_MAGIC);	\
-	sp->req->busyobj->which = (num > 0.0 ? num : 0.0);	\
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);			\
+	CHECK_OBJ_NOTNULL(req->busyobj, BUSYOBJ_MAGIC);		\
+	req->busyobj->which = (num > 0.0 ? num : 0.0);		\
 }								\
 								\
 double __match_proto__()					\
-VRT_r_bereq_##which(struct sess *sp)				\
+VRT_r_bereq_##which(struct req *req)				\
 {								\
 								\
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);			\
-	CHECK_OBJ_NOTNULL(sp->req->busyobj, BUSYOBJ_MAGIC);	\
-	return(sp->req->busyobj->which);			\
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);			\
+	CHECK_OBJ_NOTNULL(req->busyobj, BUSYOBJ_MAGIC);		\
+	return(req->busyobj->which);				\
 }
 
 BEREQ_TIMEOUT(connect_timeout)
@@ -252,118 +254,121 @@ BEREQ_TIMEOUT(between_bytes_timeout)
 /*--------------------------------------------------------------------*/
 
 const char *
-VRT_r_beresp_backend_name(const struct sess *sp)
+VRT_r_beresp_backend_name(const struct req *req)
 {
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->req->busyobj->vbc, VBC_MAGIC);
-	return(sp->req->busyobj->vbc->backend->vcl_name);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	CHECK_OBJ_NOTNULL(req->busyobj->vbc, VBC_MAGIC);
+	return(req->busyobj->vbc->backend->vcl_name);
 }
 
 struct sockaddr_storage *
-VRT_r_beresp_backend_ip(const struct sess *sp)
+VRT_r_beresp_backend_ip(const struct req *req)
 {
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->req->busyobj->vbc, VBC_MAGIC);
-	return(sp->req->busyobj->vbc->addr);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	CHECK_OBJ_NOTNULL(req->busyobj->vbc, VBC_MAGIC);
+	return(req->busyobj->vbc->addr);
 }
 
 int
-VRT_r_beresp_backend_port(const struct sess *sp)
+VRT_r_beresp_backend_port(const struct req *req)
 {
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->req->busyobj->vbc, VBC_MAGIC);
-	return (VTCP_port(sp->req->busyobj->vbc->addr));
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	CHECK_OBJ_NOTNULL(req->busyobj->vbc, VBC_MAGIC);
+	return (VTCP_port(req->busyobj->vbc->addr));
 }
 
 const char * __match_proto__()
-VRT_r_beresp_storage(struct sess *sp)
+VRT_r_beresp_storage(struct req *req)
 {
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	if (sp->req->storage_hint != NULL)
-		return (sp->req->storage_hint);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	if (req->storage_hint != NULL)
+		return (req->storage_hint);
 	else
 		return (NULL);
 }
 
 void __match_proto__()
-VRT_l_beresp_storage(struct sess *sp, const char *str, ...)
+VRT_l_beresp_storage(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->busyobj->ws, NULL, str, ap);
+	b = VRT_String(req->busyobj->ws, NULL, str, ap);
 	va_end(ap);
-	sp->req->storage_hint = b;
+	req->storage_hint = b;
 }
 
 /*--------------------------------------------------------------------*/
 
 void
-VRT_l_req_backend(const struct sess *sp, struct director *be)
+VRT_l_req_backend(struct req *req, struct director *be)
 {
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	sp->req->director = be;
+
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	req->director = be;
 }
 
 struct director *
-VRT_r_req_backend(const struct sess *sp)
+VRT_r_req_backend(struct req *req)
 {
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	return (sp->req->director);
+
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	return (req->director);
 }
 
 /*--------------------------------------------------------------------*/
 
 void
-VRT_l_req_esi(const struct sess *sp, unsigned process_esi)
+VRT_l_req_esi(struct req *req, unsigned process_esi)
 {
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	/*
 	 * Only allow you to turn of esi in the main request
 	 * else everything gets confused
 	 */
-	if(sp->req->esi_level == 0)
-		sp->req->disable_esi = !process_esi;
+	if(req->esi_level == 0)
+		req->disable_esi = !process_esi;
 }
 
 unsigned
-VRT_r_req_esi(const struct sess *sp)
+VRT_r_req_esi(struct req *req)
 {
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	return (!sp->req->disable_esi);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	return (!req->disable_esi);
 }
 
 int
-VRT_r_req_esi_level(const struct sess *sp)
+VRT_r_req_esi_level(const struct req *req)
 {
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	return(sp->req->esi_level);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	return(req->esi_level);
 }
 
 /*--------------------------------------------------------------------*/
 
 unsigned __match_proto__()
-VRT_r_req_can_gzip(struct sess *sp)
+VRT_r_req_can_gzip(struct req *req)
 {
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	return (RFC2616_Req_Gzip(sp->req->http));
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	return (RFC2616_Req_Gzip(req->http));
 }
 
 
 /*--------------------------------------------------------------------*/
 
 int
-VRT_r_req_restarts(const struct sess *sp)
+VRT_r_req_restarts(const struct req *req)
 {
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	return (sp->req->restarts);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	return (req->restarts);
 }
 
 /*--------------------------------------------------------------------
@@ -374,10 +379,10 @@ VRT_r_req_restarts(const struct sess *sp)
 #define VRT_DO_EXP(which, exp, fld, offset, extra)		\
 								\
 void __match_proto__()						\
-VRT_l_##which##_##fld(struct sess *sp, double a)		\
+VRT_l_##which##_##fld(struct req *req, double a)		\
 {								\
 								\
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);			\
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);			\
 	if (a > 0.)						\
 		a += offset;					\
 	EXP_Set_##fld(&exp, a);					\
@@ -385,57 +390,58 @@ VRT_l_##which##_##fld(struct sess *sp, double a)		\
 }								\
 								\
 double __match_proto__()					\
-VRT_r_##which##_##fld(struct sess *sp)				\
+VRT_r_##which##_##fld(struct req *req)				\
 {								\
 								\
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);			\
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);			\
 	return(EXP_Get_##fld(&exp) - offset);			\
 }
 
 static void
-vrt_wsp_exp(const struct sess *sp, unsigned xid, const struct exp *e)
+vrt_wsp_exp(struct req *req, unsigned xid, const struct exp *e)
 {
-	VSLb(sp->req->vsl, SLT_TTL, "%u VCL %.0f %.0f %.0f %.0f %.0f",
-	    xid, e->ttl - (sp->req->t_req - e->entered), e->grace, e->keep,
-	    sp->req->t_req, e->age + (sp->req->t_req - e->entered));
-}
-
-VRT_DO_EXP(req, sp->req->exp, ttl, 0, )
-VRT_DO_EXP(req, sp->req->exp, grace, 0, )
-VRT_DO_EXP(req, sp->req->exp, keep, 0, )
-
-VRT_DO_EXP(obj, sp->req->obj->exp, grace, 0,
-   EXP_Rearm(sp->req->obj);
-   vrt_wsp_exp(sp, sp->req->obj->xid, &sp->req->obj->exp);)
-VRT_DO_EXP(obj, sp->req->obj->exp, ttl,
-   (sp->req->t_req - sp->req->obj->exp.entered),
-   EXP_Rearm(sp->req->obj);
-   vrt_wsp_exp(sp, sp->req->obj->xid, &sp->req->obj->exp);)
-VRT_DO_EXP(obj, sp->req->obj->exp, keep, 0,
-   EXP_Rearm(sp->req->obj);
-   vrt_wsp_exp(sp, sp->req->obj->xid, &sp->req->obj->exp);)
-
-VRT_DO_EXP(beresp, sp->req->busyobj->exp, grace, 0,
-   vrt_wsp_exp(sp, sp->req->xid, &sp->req->busyobj->exp);)
-VRT_DO_EXP(beresp, sp->req->busyobj->exp, ttl, 0,
-   vrt_wsp_exp(sp, sp->req->xid, &sp->req->busyobj->exp);)
-VRT_DO_EXP(beresp, sp->req->busyobj->exp, keep, 0,
-   vrt_wsp_exp(sp, sp->req->xid, &sp->req->busyobj->exp);)
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	VSLb(req->vsl, SLT_TTL, "%u VCL %.0f %.0f %.0f %.0f %.0f",
+	    xid, e->ttl - (req->t_req - e->entered), e->grace, e->keep,
+	    req->t_req, e->age + (req->t_req - e->entered));
+}
+
+VRT_DO_EXP(req, req->exp, ttl, 0, )
+VRT_DO_EXP(req, req->exp, grace, 0, )
+VRT_DO_EXP(req, req->exp, keep, 0, )
+
+VRT_DO_EXP(obj, req->obj->exp, grace, 0,
+   EXP_Rearm(req->obj);
+   vrt_wsp_exp(req, req->obj->xid, &req->obj->exp);)
+VRT_DO_EXP(obj, req->obj->exp, ttl,
+   (req->t_req - req->obj->exp.entered),
+   EXP_Rearm(req->obj);
+   vrt_wsp_exp(req, req->obj->xid, &req->obj->exp);)
+VRT_DO_EXP(obj, req->obj->exp, keep, 0,
+   EXP_Rearm(req->obj);
+   vrt_wsp_exp(req, req->obj->xid, &req->obj->exp);)
+
+VRT_DO_EXP(beresp, req->busyobj->exp, grace, 0,
+   vrt_wsp_exp(req, req->xid, &req->busyobj->exp);)
+VRT_DO_EXP(beresp, req->busyobj->exp, ttl, 0,
+   vrt_wsp_exp(req, req->xid, &req->busyobj->exp);)
+VRT_DO_EXP(beresp, req->busyobj->exp, keep, 0,
+   vrt_wsp_exp(req, req->xid, &req->busyobj->exp);)
 
 /*--------------------------------------------------------------------
  * req.xid
  */
 
 const char * __match_proto__()
-VRT_r_req_xid(struct sess *sp)
+VRT_r_req_xid(struct req *req)
 {
 	char *p;
 	int size;
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 
-	size = snprintf(NULL, 0, "%u", sp->req->xid) + 1;
-	AN(p = WS_Alloc(sp->req->http->ws, size));
-	assert(snprintf(p, size, "%u", sp->req->xid) < size);
+	size = snprintf(NULL, 0, "%u", req->xid) + 1;
+	AN(p = WS_Alloc(req->http->ws, size));
+	assert(snprintf(p, size, "%u", req->xid) < size);
 	return (p);
 }
 
@@ -443,19 +449,19 @@ VRT_r_req_xid(struct sess *sp)
 
 #define REQ_BOOL(hash_var)					\
 void __match_proto__()						\
-VRT_l_req_##hash_var(struct sess *sp, unsigned val)		\
+VRT_l_req_##hash_var(struct req *req, unsigned val)		\
 {								\
 								\
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);			\
-	sp->req->hash_var = val ? 1 : 0;				\
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);			\
+	req->hash_var = val ? 1 : 0;				\
 }								\
 								\
 unsigned __match_proto__()					\
-VRT_r_req_##hash_var(struct sess *sp)				\
+VRT_r_req_##hash_var(struct req *req)				\
 {								\
 								\
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);			\
-	return(sp->req->hash_var);					\
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);			\
+	return(req->hash_var);					\
 }
 
 REQ_BOOL(hash_ignore_busy)
@@ -464,46 +470,46 @@ REQ_BOOL(hash_always_miss)
 /*--------------------------------------------------------------------*/
 
 struct sockaddr_storage *
-VRT_r_client_ip(struct sess *sp)
+VRT_r_client_ip(struct req *req)
 {
 
-	return (&sp->sockaddr);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	return (&req->sp->sockaddr);
 }
 
 struct sockaddr_storage *
-VRT_r_server_ip(struct sess *sp)
+VRT_r_server_ip(struct req *req)
 {
 	int i;
 
-	if (sp->mysockaddr.ss_family == AF_UNSPEC) {
-		i = getsockname(sp->fd,
-		    (void*)&sp->mysockaddr, &sp->mysockaddrlen);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	if (req->sp->mysockaddr.ss_family == AF_UNSPEC) {
+		i = getsockname(req->sp->fd,
+		    (void*)&req->sp->mysockaddr, &req->sp->mysockaddrlen);
 		assert(VTCP_Check(i));
 	}
 
-	return (&sp->mysockaddr);
+	return (&req->sp->mysockaddr);
 }
 
 const char*
-VRT_r_server_identity(struct sess *sp)
+VRT_r_server_identity(struct req *req)
 {
-	(void)sp;
 
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	if (heritage.identity[0] != '\0')
 		return (heritage.identity);
 	else
 		return (heritage.name);
 }
 
-
 const char*
-VRT_r_server_hostname(struct sess *sp)
+VRT_r_server_hostname(struct req *req)
 {
-	(void)sp;
 
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	if (vrt_hostname[0] == '\0')
 		AZ(gethostname(vrt_hostname, sizeof(vrt_hostname)));
-
 	return (vrt_hostname);
 }
 
@@ -512,43 +518,44 @@ VRT_r_server_hostname(struct sess *sp)
  */
 
 int
-VRT_r_server_port(struct sess *sp)
+VRT_r_server_port(struct req *req)
 {
 	int i;
 
-	if (sp->mysockaddr.ss_family == AF_UNSPEC) {
-		i = getsockname(sp->fd,
-		    (void*)&sp->mysockaddr, &sp->mysockaddrlen);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	if (req->sp->mysockaddr.ss_family == AF_UNSPEC) {
+		i = getsockname(req->sp->fd,
+		    (void*)&req->sp->mysockaddr, &req->sp->mysockaddrlen);
 		assert(VTCP_Check(i));
 	}
-	return (VTCP_port(&sp->mysockaddr));
+	return (VTCP_port(&req->sp->mysockaddr));
 }
 
 /*--------------------------------------------------------------------*/
 
 int
-VRT_r_obj_hits(const struct sess *sp)
+VRT_r_obj_hits(const struct req *req)
 {
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->req->obj, OBJECT_MAGIC);	/* XXX */
-	return (sp->req->obj->hits);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);	/* XXX */
+	return (req->obj->hits);
 }
 
 double
-VRT_r_obj_lastuse(const struct sess *sp)
+VRT_r_obj_lastuse(const struct req *req)
 {
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->req->obj, OBJECT_MAGIC);	/* XXX */
-	return (VTIM_real() - sp->req->obj->last_use);
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);	/* XXX */
+	return (VTIM_real() - req->obj->last_use);
 }
 
 unsigned
-VRT_r_req_backend_healthy(const struct sess *sp)
+VRT_r_req_backend_healthy(struct req *req)
 {
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->req->director, DIRECTOR_MAGIC);
-	return (VDI_Healthy(sp->req->director, sp));
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	CHECK_OBJ_NOTNULL(req->director, DIRECTOR_MAGIC);
+	return (VDI_Healthy(req->director, req->sp));
 }
 
diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py
index 0f7b360..0c1c02e 100755
--- a/lib/libvcl/generate.py
+++ b/lib/libvcl/generate.py
@@ -107,361 +107,361 @@ sp_variables = (
 		'IP',
 		( 'proc',),
 		( ),
-		'struct sess *'
+		'struct req *'
 	),
 	('client.identity',
 		'STRING',
 		( 'proc',),
 		( 'proc',),
-		'const struct sess *'
+		'struct req *'
 	),
 	('server.ip',
 		'IP',
 		( 'proc',),
 		( ),
-		'struct sess *'
+		'struct req *'
 	),
 	('server.hostname',
 		'STRING',
 		( 'proc',),
 		( ),
-		'struct sess *'
+		'struct req *'
 	),
 	('server.identity',
 		'STRING',
 		( 'proc',),
 		( ),
-		'struct sess *'
+		'struct req *'
 	),
 	('server.port',
 		'INT',
 		( 'proc',),
 		( ),
-		'struct sess *'
+		'struct req *'
 	),
 	('req.request',
 		'STRING',
 		( 'proc',),
 		( 'proc',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('req.url',
 		'STRING',
 		( 'proc',),
 		( 'proc',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('req.proto',
 		'STRING',
 		( 'proc',),
 		( 'proc',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('req.http.',
 		'HDR_REQ',
 		( 'proc',),
 		( 'proc',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('req.backend',
 		'BACKEND',
 		( 'proc',),
 		( 'proc',),
-		'const struct sess *'
+		'struct req *'
 	),
 	('req.restarts',
 		'INT',
 		( 'proc',),
 		( ),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('req.esi_level',
 		'INT',
 		( 'proc',),
 		( ),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('req.ttl',
 		'DURATION',
 		( 'proc',),
 		( 'proc',),
-		'struct sess *'
+		'struct req *'
 	),
 	('req.grace',
 		'DURATION',
 		( 'proc',),
 		( 'proc',),
-		'struct sess *'
+		'struct req *'
 	),
 	('req.keep',
 		'DURATION',
 		( 'proc',),
 		( 'proc',),
-		'struct sess *'
+		'struct req *'
 	),
 	('req.xid',
 		'STRING',
 		( 'proc',),
 		( ),
-		'struct sess *'
+		'struct req *'
 	),
 	('req.esi',
 		'BOOL',
 		( 'recv', 'fetch', 'deliver', 'error',),
 		( 'recv', 'fetch', 'deliver', 'error',),
-		'const struct sess *'
+		'struct req *'
 	),
 	('req.can_gzip',
 		'BOOL',
 		( 'proc',),
 		( ),
-		'struct sess *'
+		'struct req *'
 	),
 	('req.backend.healthy',
 		'BOOL',
 		( 'proc',),
 		( ),
-		'const struct sess *'
+		'struct req *'
 	),
 	('req.hash_ignore_busy',
 		'BOOL',
 		( 'recv',),
 		( 'recv',),
-		'struct sess *'
+		'struct req *'
 	),
 	('req.hash_always_miss',
 		'BOOL',
 		( 'recv',),
 		( 'recv',),
-		'struct sess *'
+		'struct req *'
 	),
 	('bereq.request',
 		'STRING',
 		( 'pipe', 'pass', 'miss', 'fetch',),
 		( 'pipe', 'pass', 'miss', 'fetch',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('bereq.url',
 		'STRING',
 		( 'pipe', 'pass', 'miss', 'fetch',),
 		( 'pipe', 'pass', 'miss', 'fetch',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('bereq.proto',
 		'STRING',
 		( 'pipe', 'pass', 'miss', 'fetch',),
 		( 'pipe', 'pass', 'miss', 'fetch',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('bereq.http.',
 		'HDR_BEREQ',
 		( 'pipe', 'pass', 'miss', 'fetch',),
 		( 'pipe', 'pass', 'miss', 'fetch',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('bereq.connect_timeout',
 		'DURATION',
 		( 'pipe', 'pass', 'miss',),
 		( 'pipe', 'pass', 'miss',),
-		'struct sess *'
+		'struct req *'
 	),
 	('bereq.first_byte_timeout',
 		'DURATION',
 		( 'pass', 'miss',),
 		( 'pass', 'miss',),
-		'struct sess *'
+		'struct req *'
 	),
 	('bereq.between_bytes_timeout',
 		'DURATION',
 		( 'pass', 'miss',),
 		( 'pass', 'miss',),
-		'struct sess *'
+		'struct req *'
 	),
 	('beresp.proto',
 		'STRING',
 		( 'fetch',),
 		( 'fetch',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('beresp.saintmode',
 		'DURATION',
 		( ),
 		( 'fetch',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('beresp.status',
 		'INT',
 		( 'fetch',),
 		( 'fetch',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('beresp.response',
 		'STRING',
 		( 'fetch',),
 		( 'fetch',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('beresp.http.',
 		'HDR_BERESP',
 		( 'fetch',),
 		( 'fetch',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('beresp.do_esi',
 		'BOOL',
 		( 'fetch',),
 		( 'fetch',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('beresp.do_stream',
 		'BOOL',
 		( 'fetch',),
 		( 'fetch',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('beresp.do_gzip',
 		'BOOL',
 		( 'fetch',),
 		( 'fetch',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('beresp.do_gunzip',
 		'BOOL',
 		( 'fetch',),
 		( 'fetch',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('beresp.do_pass',
 		'BOOL',
 		( 'fetch',),
 		( 'fetch',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('beresp.ttl',
 		'DURATION',
 		( 'fetch',),
 		( 'fetch',),
-		'struct sess *'
+		'struct req *'
 	),
 	('beresp.grace',
 		'DURATION',
 		( 'fetch',),
 		( 'fetch',),
-		'struct sess *'
+		'struct req *'
 	),
 	('beresp.keep',
 		'DURATION',
 		( 'fetch',),
 		( 'fetch',),
-		'struct sess *'
+		'struct req *'
 	),
 	('beresp.backend.name',
 		'STRING',
 		( 'fetch',),
 		( ),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('beresp.backend.ip',
 		'IP',
 		( 'fetch',),
 		( ),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('beresp.backend.port',
 		'INT',
 		( 'fetch',),
 		( ),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('beresp.storage',
 		'STRING',
 		( 'fetch',),
 		( 'fetch',),
-		'struct sess *'
+		'struct req *'
 	),
 	('obj.proto',
 		'STRING',
 		( 'hit', 'error',),
 		( 'hit', 'error',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('obj.status',
 		'INT',
 		( 'error',),
 		( 'error',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('obj.response',
 		'STRING',
 		( 'error',),
 		( 'error',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('obj.hits',
 		'INT',
 		( 'hit', 'deliver',),
 		( ),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('obj.http.',
 		'HDR_OBJ',
 		( 'hit', 'error',),
 		( 'error',),		# XXX ?
-		'const struct sess *'
+		'const struct req *'
 	),
 	('obj.ttl',
 		'DURATION',
 		( 'hit', 'error',),
 		( 'hit', 'error',),
-		'struct sess *'
+		'struct req *'
 	),
 	('obj.grace',
 		'DURATION',
 		( 'hit', 'error',),
 		( 'hit', 'error',),
-		'struct sess *'
+		'struct req *'
 	),
 	('obj.keep',
 		'DURATION',
 		( 'hit', 'error',),
 		( 'hit', 'error',),
-		'struct sess *'
+		'struct req *'
 	),
 	('obj.lastuse',
 		'DURATION',
 		( 'hit', 'deliver', 'error',),
 		( ),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('resp.proto',
 		'STRING',
 		( 'deliver',),
 		( 'deliver',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('resp.status',
 		'INT',
 		( 'deliver',),
 		( 'deliver',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('resp.response',
 		'STRING',
 		( 'deliver',),
 		( 'deliver',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('resp.http.',
 		'HDR_RESP',
 		( 'deliver',),
 		( 'deliver',),
-		'const struct sess *'
+		'const struct req *'
 	),
 	('now',
 		'TIME',
 		( 'all',),
 		( ),
-		'const struct sess *'
+		'const struct req *'
 	),
 )
 
@@ -831,7 +831,7 @@ for i in sp_variables:
 	fo.write("\t{ \"%s\", %s, %d,\n" % (i[0], typ, len(i[0])))
 
 	if len(i[2]) > 0:
-		fo.write('\t    "VRT_r_%s(sp)",\n' % cnam)
+		fo.write('\t    "VRT_r_%s(req)",\n' % cnam)
 		if typ != "HEADER":
 			fh.write(ctyp + " VRT_r_%s(%s);\n" % (cnam, i[4]))
 	else:
@@ -839,7 +839,7 @@ for i in sp_variables:
 	restrict(fo, i[2])
 
 	if len(i[3]) > 0:
-		fo.write('\t    "VRT_l_%s(sp, ",\n' % cnam)
+		fo.write('\t    "VRT_l_%s(req, ",\n' % cnam)
 		if typ != "HEADER":
 			fh.write("void VRT_l_%s(%s, " % (cnam, i[4]))
 			if typ != "STRING":



More information about the varnish-commit mailing list