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) ...@@ -156,20 +156,21 @@ HSH_DeleteObjHead(struct dstat *ds, struct objhead *oh)
} }
void void
HSH_AddString(const struct sess *sp, const char *str) HSH_AddString(struct req *req, const char *str)
{ {
int l; int l;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
if (str == NULL) if (str == NULL)
str = ""; str = "";
l = strlen(str); l = strlen(str);
AN(sp->req->sha256ctx); AN(req->sha256ctx);
SHA256_Update(sp->req->sha256ctx, str, l); SHA256_Update(req->sha256ctx, str, l);
SHA256_Update(sp->req->sha256ctx, "#", 1); SHA256_Update(req->sha256ctx, "#", 1);
if (cache_param->log_hash) 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) ...@@ -93,27 +93,27 @@ VRT_acl_log(const struct sess *sp, const char *msg)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static struct http * 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; struct http *hp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
switch (where) { switch (where) {
case HDR_REQ: case HDR_REQ:
hp = sp->req->http; hp = req->http;
break; break;
case HDR_BEREQ: case HDR_BEREQ:
hp = sp->req->busyobj->bereq; hp = req->busyobj->bereq;
break; break;
case HDR_BERESP: case HDR_BERESP:
hp = sp->req->busyobj->beresp; hp = req->busyobj->beresp;
break; break;
case HDR_RESP: case HDR_RESP:
hp = sp->req->resp; hp = req->resp;
break; break;
case HDR_OBJ: case HDR_OBJ:
CHECK_OBJ_NOTNULL(sp->req->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);
hp = sp->req->obj->http; hp = req->obj->http;
break; break;
default: default:
INCOMPL(); INCOMPL();
...@@ -123,13 +123,13 @@ vrt_selecthttp(const struct sess *sp, enum gethdr_e where) ...@@ -123,13 +123,13 @@ vrt_selecthttp(const struct sess *sp, enum gethdr_e where)
} }
char * 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; char *p;
struct http *hp; struct http *hp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
hp = vrt_selecthttp(sp, where); hp = vrt_selecthttp(req, where);
if (!http_GetHdr(hp, n, &p)) if (!http_GetHdr(hp, n, &p))
return (NULL); return (NULL);
return (p); return (p);
...@@ -215,22 +215,22 @@ VRT_WrkString(const struct sess *sp, const char *p, ...) ...@@ -215,22 +215,22 @@ VRT_WrkString(const struct sess *sp, const char *p, ...)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
void 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, ...) const char *p, ...)
{ {
struct http *hp; struct http *hp;
va_list ap; va_list ap;
char *b; char *b;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
hp = vrt_selecthttp(sp, where); hp = vrt_selecthttp(req, where);
va_start(ap, p); va_start(ap, p);
if (p == NULL) { if (p == NULL) {
http_Unset(hp, hdr); http_Unset(hp, hdr);
} else { } else {
b = VRT_String(hp->ws, hdr + 1, p, ap); b = VRT_String(hp->ws, hdr + 1, p, ap);
if (b == NULL) { if (b == NULL) {
VSLb(sp->req->vsl, SLT_LostHeader, "%s", hdr + 1); VSLb(req->vsl, SLT_LostHeader, "%s", hdr + 1);
} else { } else {
http_Unset(hp, hdr); http_Unset(hp, hdr);
http_SetHeader(hp, b); http_SetHeader(hp, b);
...@@ -242,16 +242,16 @@ VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr, ...@@ -242,16 +242,16 @@ VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr,
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
void 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); assert(hand == VCL_RET_OK);
return; return;
} }
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
assert(hand < VCL_RET_MAX); assert(hand < VCL_RET_MAX);
sp->req->handling = hand; req->handling = hand;
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
...@@ -259,18 +259,18 @@ VRT_handling(const struct sess *sp, unsigned hand) ...@@ -259,18 +259,18 @@ VRT_handling(const struct sess *sp, unsigned hand)
*/ */
void void
VRT_hashdata(const struct sess *sp, const char *str, ...) VRT_hashdata(struct req *req, const char *str, ...)
{ {
va_list ap; va_list ap;
const char *p; const char *p;
HSH_AddString(sp, str); HSH_AddString(req, str);
va_start(ap, str); va_start(ap, str);
while (1) { while (1) {
p = va_arg(ap, const char *); p = va_arg(ap, const char *);
if (p == vrt_magic_string_end) if (p == vrt_magic_string_end)
break; break;
HSH_AddString(sp, p); HSH_AddString(req, p);
} }
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
*/ */
struct sess; struct sess;
struct req;
struct worker; struct worker;
struct object; struct object;
...@@ -56,7 +57,7 @@ struct objcore *HSH_Lookup(struct sess *sp); ...@@ -56,7 +57,7 @@ struct objcore *HSH_Lookup(struct sess *sp);
void HSH_Ref(struct objcore *o); void HSH_Ref(struct objcore *o);
void HSH_Drop(struct worker *, struct object **); void HSH_Drop(struct worker *, struct object **);
void HSH_Init(const struct hash_slinger *slinger); 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_Insert(struct worker *, const void *hash, struct objcore *);
void HSH_Purge(const struct sess *, struct objhead *, double ttl, double grace); void HSH_Purge(const struct sess *, struct objhead *, double ttl, double grace);
void HSH_config(const char *h_arg); void HSH_config(const char *h_arg);
......
...@@ -161,12 +161,12 @@ void VRT_error(const struct sess *, unsigned, const char *); ...@@ -161,12 +161,12 @@ void VRT_error(const struct sess *, unsigned, const char *);
int VRT_switch_config(const char *); int VRT_switch_config(const char *);
enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ, HDR_BERESP }; 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 *); char *VRT_GetHdr(const struct req *, enum gethdr_e where, const char *);
void VRT_SetHdr(const struct sess *, enum gethdr_e where, const char *, void VRT_SetHdr(struct req *, enum gethdr_e where, const char *,
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 */ /* Simple stuff */
int VRT_strcmp(const char *s1, const char *s2); int VRT_strcmp(const char *s1, const char *s2);
...@@ -217,9 +217,9 @@ char *VRT_time_string(const struct sess *sp, double); ...@@ -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_bool_string(const struct sess *sp, unsigned);
const char *VRT_backend_string(const struct sess *sp, const struct director *d); const char *VRT_backend_string(const struct sess *sp, const struct director *d);
#define VRT_done(sp, hand) \ #define VRT_done(req, hand) \
do { \ do { \
VRT_handling(sp, hand); \ VRT_handling(req, hand); \
return (1); \ return (1); \
} while (0) } while (0)
......
...@@ -77,7 +77,7 @@ parse_error(struct vcc *tl) ...@@ -77,7 +77,7 @@ parse_error(struct vcc *tl)
Fb(tl, 1, ", 0\n"); Fb(tl, 1, ", 0\n");
} }
Fb(tl, 1, ");\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) ...@@ -224,7 +224,7 @@ parse_hash_data(struct vcc *tl)
vcc_NextToken(tl); vcc_NextToken(tl);
SkipToken(tl, '('); SkipToken(tl, '(');
Fb(tl, 1, "VRT_hashdata(sp, "); Fb(tl, 1, "VRT_hashdata(req, ");
vcc_Expr(tl, STRING_LIST); vcc_Expr(tl, STRING_LIST);
ERRCHK(tl); ERRCHK(tl);
Fb(tl, 0, ");\n"); Fb(tl, 0, ");\n");
...@@ -259,7 +259,7 @@ parse_return(struct vcc *tl) ...@@ -259,7 +259,7 @@ parse_return(struct vcc *tl)
#define VCL_RET_MAC(l, U, B) \ #define VCL_RET_MAC(l, U, B) \
do { \ do { \
if (vcc_IdIs(tl->t, #l)) { \ 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);\ vcc_ProcAction(tl->curproc, VCL_RET_##U, tl->t);\
retval = 1; \ retval = 1; \
} \ } \
......
...@@ -59,10 +59,10 @@ vcc_Var_Wildcard(struct vcc *tl, const struct token *t, const struct symbol *wc) ...@@ -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); bprintf(buf, "\\%03o%s:", (unsigned)l, v->name + vh->len);
v->hdr = TlDup(tl, buf); 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); 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); v->lname = TlDup(tl, buf);
sym = VCC_AddSymbolTok(tl, t, SYM_VAR); 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