Commit 8b0b76f6 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

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.
parent cc16852f
......@@ -51,6 +51,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
......
......@@ -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 *, ...);
......
......@@ -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 {
......
......@@ -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",
......
......@@ -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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment