Commit b4d76fea authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

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

parent 30ecc418
......@@ -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);
}
/*---------------------------------------------------------------------
......
......@@ -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);
}
}
......
......@@ -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);
......
......@@ -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)
......
......@@ -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; \
} \
......
......@@ -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);
......
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