[master] 2d53dfe Start moving the backend VCL variables to use busyobj rather than req
Poul-Henning Kamp
phk at varnish-cache.org
Mon Apr 22 12:42:00 CEST 2013
commit 2d53dfe4006d54ee783f9513c36b55f99789108e
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Apr 22 10:41:38 2013 +0000
Start moving the backend VCL variables to use busyobj rather than req
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 16f8c8b..8378095 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -63,38 +63,47 @@ vrt_do_string(const struct http *hp, int fld,
#define VRT_DO_HDR(obj, hdr, http, fld) \
void \
-VRT_l_##obj##_##hdr(const struct req *req, const char *p, ...) \
+VRT_l_##obj##_##hdr(const struct CPAR *px, const char *p, ...) \
{ \
va_list ap; \
\
- CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \
+ CHECK_OBJ_NOTNULL(px, CMAGIC); \
va_start(ap, p); \
vrt_do_string(http, fld, #obj "." #hdr, p, ap); \
va_end(ap); \
} \
\
const char * \
-VRT_r_##obj##_##hdr(const struct req *req) \
+VRT_r_##obj##_##hdr(const struct CPAR *px) \
{ \
- CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \
+ CHECK_OBJ_NOTNULL(px, CMAGIC); \
CHECK_OBJ_NOTNULL(http, HTTP_MAGIC); \
return (http->hd[fld].b); \
}
-VRT_DO_HDR(req, method, req->http, HTTP_HDR_METHOD)
-VRT_DO_HDR(req, request, req->http, HTTP_HDR_METHOD)
-VRT_DO_HDR(req, url, req->http, HTTP_HDR_URL)
-VRT_DO_HDR(req, proto, req->http, HTTP_HDR_PROTO)
-VRT_DO_HDR(bereq, method, req->busyobj->bereq, HTTP_HDR_METHOD)
-VRT_DO_HDR(bereq, request, req->busyobj->bereq, HTTP_HDR_METHOD)
-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 CPAR req
+#define CMAGIC REQ_MAGIC
+VRT_DO_HDR(req, method, px->http, HTTP_HDR_METHOD)
+VRT_DO_HDR(req, request, px->http, HTTP_HDR_METHOD)
+VRT_DO_HDR(req, url, px->http, HTTP_HDR_URL)
+VRT_DO_HDR(req, proto, px->http, HTTP_HDR_PROTO)
+VRT_DO_HDR(obj, proto, px->obj->http, HTTP_HDR_PROTO)
+VRT_DO_HDR(obj, response, px->obj->http, HTTP_HDR_RESPONSE)
+VRT_DO_HDR(resp, proto, px->resp, HTTP_HDR_PROTO)
+VRT_DO_HDR(resp, response, px->resp, HTTP_HDR_RESPONSE)
+#undef CPAR
+#undef CMAGIC
+
+#define CPAR busyobj
+#define CMAGIC BUSYOBJ_MAGIC
+VRT_DO_HDR(bereq, method, px->bereq, HTTP_HDR_METHOD)
+VRT_DO_HDR(bereq, request, px->bereq, HTTP_HDR_METHOD)
+VRT_DO_HDR(bereq, url, px->bereq, HTTP_HDR_URL)
+VRT_DO_HDR(bereq, proto, px->bereq, HTTP_HDR_PROTO)
+VRT_DO_HDR(beresp, proto, px->beresp, HTTP_HDR_PROTO)
+VRT_DO_HDR(beresp, response, px->beresp, HTTP_HDR_RESPONSE)
+#undef CPAR
+#undef CMAGIC
/*--------------------------------------------------------------------*/
diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py
index 5df3fd8..2bd958e 100755
--- a/lib/libvcl/generate.py
+++ b/lib/libvcl/generate.py
@@ -241,25 +241,25 @@ sp_variables = (
'STRING',
( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',),
( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',),
- 'cR'
+ 'cB'
),
('bereq.request',
'STRING',
( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',),
( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',),
- 'cR'
+ 'cB'
),
('bereq.url',
'STRING',
( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',),
( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',),
- 'cR'
+ 'cB'
),
('bereq.proto',
'STRING',
( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',),
( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',),
- 'cR'
+ 'cB'
),
('bereq.http.',
'HEADER',
@@ -289,7 +289,7 @@ sp_variables = (
'STRING',
( 'backend_response',),
( 'backend_response',),
- 'cR'
+ 'cB'
),
('beresp.saintmode',
'DURATION',
@@ -307,7 +307,7 @@ sp_variables = (
'STRING',
( 'backend_response',),
( 'backend_response',),
- 'cR'
+ 'cB'
),
('beresp.http.',
'HEADER',
@@ -859,10 +859,19 @@ def mk_proto(c, r=False):
for i in c:
if i == "c" and not r:
s += " const"
- if i == "R":
+ elif i == "c":
+ pass
+ elif i == "R":
if r:
s += " const"
s += " struct req *"
+ elif i == "B":
+ if r:
+ s += " const"
+ s += " struct busyobj *"
+ else:
+ print("Unknown args-spec char '%s'" % i)
+ exit(1)
return s[1:]
@@ -873,8 +882,13 @@ def mk_args(c, r=False):
for i in c:
if i == "c":
continue;
- if i == "R":
+ elif i == "R":
s += "req"
+ elif i == "B":
+ s += "bo"
+ else:
+ print("Unknown args-spec char '%s'" % i)
+ exit(1)
if s != "" and not r:
s += ","
return s
More information about the varnish-commit
mailing list