[master] 8b0b76f Since we have already begun reworking the VCL type definitions, move the goal-posts a serious distance while we're at it:
Poul-Henning Kamp
phk at varnish-cache.org
Thu Oct 18 19:19:27 CEST 2012
commit 8b0b76f6434b81db0215a4568b0f0aaac0b88d2c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Oct 18 17:17:57 2012 +0000
Since we have already begun reworking the VCL type definitions, move
the goal-posts a serious distance while we're at it:
We can use the thread workspace for small temporary allocations during
VCL execution, use this to allocate a compound type for the HEADER
type, to get us closer to typedef-ability for VCL mapped types.
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index a2dd8cd..c58af62 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -53,6 +53,22 @@ const void * const vrt_magic_string_end = &vrt_magic_string_end;
/*--------------------------------------------------------------------*/
+const struct gethdr_s *
+VRT_MkGethdr(struct req *req, enum gethdr_e where, const char *what)
+{
+ struct gethdr_s *retval;
+
+ CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+ retval = (void*)WS_Alloc(req->wrk->aws, sizeof *retval);
+ AN(retval);
+ retval->where = where;
+ retval->what = what;
+ return (retval);
+}
+
+
+/*--------------------------------------------------------------------*/
+
void
VRT_error(struct req *req, unsigned code, const char *reason)
{
diff --git a/include/vrt.h b/include/vrt.h
index 2029f7a..ec07f65 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -38,6 +38,13 @@ struct director;
struct VCL_conf;
struct sockaddr_storage;
+enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ, HDR_BERESP };
+
+struct gethdr_s {
+ enum gethdr_e where;
+ const char *what;
+};
+
/*
* A backend probe specification
*/
@@ -158,7 +165,7 @@ int VRT_rewrite(const char *, const char *);
void VRT_error(struct req *, unsigned, const char *);
int VRT_switch_config(const char *);
-enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ, HDR_BERESP };
+const struct gethdr_s *VRT_MkGethdr(struct req *,enum gethdr_e, 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 *, ...);
diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c
index 1b6bf12..c3fbef4 100644
--- a/lib/libvcl/vcc_expr.c
+++ b/lib/libvcl/vcc_expr.c
@@ -605,7 +605,8 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym)
vcc_ErrWhere(tl, tl->t);
return;
}
- e1 = vcc_mk_expr(VOID, "%s, \"%s\"", v->http, v->hdr);
+ e1 = vcc_mk_expr(VOID, "VRT_MkGethdr(req, %s, \"%s\")",
+ v->http, v->hdr);
if (*p != '\0')
SkipToken(tl, ',');
} else {
diff --git a/lib/libvcl/vmodtool.py b/lib/libvcl/vmodtool.py
index e7edbde..56e361b 100755
--- a/lib/libvcl/vmodtool.py
+++ b/lib/libvcl/vmodtool.py
@@ -56,7 +56,7 @@ ctypes = {
'REAL': "double",
'DURATION': "double",
'INT': "long",
- 'HEADER': "enum gethdr_e, const char *",
+ 'HEADER': "const struct gethdr_s *",
'PRIV_VCL': "struct vmod_priv *",
'PRIV_CALL': "struct vmod_priv *",
'VOID': "void",
diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index e31b0c8..b90d847 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -169,12 +169,12 @@ vmod_syslog(struct req *req, long fac, const char *fmt, ...)
}
void __match_proto__(td_std_collect)
-vmod_collect(struct req *req, enum gethdr_e e, const char *h)
+vmod_collect(struct req *req, const struct gethdr_s *hdr)
{
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- if (e == HDR_REQ)
- http_CollectHdr(req->http, h);
- else if (e == HDR_BERESP && req->busyobj != NULL)
- http_CollectHdr(req->busyobj->beresp, h);
+ if (hdr->where == HDR_REQ)
+ http_CollectHdr(req->http, hdr->what);
+ else if (hdr->where == HDR_BERESP && req->busyobj != NULL)
+ http_CollectHdr(req->busyobj->beresp, hdr->what);
}
More information about the varnish-commit
mailing list