Commit 8f451fa7 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Tollef Fog Heen

Move request vary string from wrk to sess

parent a5e2100e
......@@ -300,9 +300,6 @@ struct worker {
/* Lookup stuff */
struct SHA256Context *sha256ctx;
uint8_t *vary_b;
uint8_t *vary_l;
uint8_t *vary_e;
struct http_conn htc[1];
struct ws ws[1];
......@@ -554,6 +551,11 @@ struct sess {
unsigned char digest[DIGEST_LEN];
/* Built Vary string */
uint8_t *vary_b;
uint8_t *vary_l;
uint8_t *vary_e;
struct http_conn htc[1];
/* Timestamps, all on TIM_real() timescale */
......@@ -884,7 +886,7 @@ void RES_StreamPoll(const struct sess *sp);
/* cache_vary.c */
struct vsb *VRY_Create(const struct sess *sp, const struct http *hp);
int VRY_Match(const struct sess *sp, const uint8_t *vary);
int VRY_Match(struct sess *sp, const uint8_t *vary);
/* cache_vcl.c */
void VCL_Init(void);
......
......@@ -1028,28 +1028,23 @@ cnt_lookup(struct sess *sp)
struct objcore *oc;
struct object *o;
struct objhead *oh;
struct worker *wrk;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
wrk = sp->wrk;
AZ(wrk->vary_b);
AZ(wrk->vary_l);
AZ(wrk->vary_e);
(void)WS_Reserve(wrk->ws, 0);
wrk->vary_b = (void*)wrk->ws->f;
wrk->vary_e = (void*)wrk->ws->r;
wrk->vary_b[2] = '\0';
if (sp->hash_objhead == NULL) {
/* Not a waiting list return */
AZ(sp->vary_b);
AZ(sp->vary_l);
AZ(sp->vary_e);
(void)WS_Reserve(sp->ws, 0);
sp->vary_b = (void*)sp->ws->f;
sp->vary_e = (void*)sp->ws->r;
sp->vary_b[2] = '\0';
}
oc = HSH_Lookup(sp, &oh);
WS_Release(wrk->ws, 0);
wrk->vary_b = NULL;
wrk->vary_l = NULL;
wrk->vary_e = NULL;
if (oc == NULL) {
/*
* We lost the session to a busy object, disembark the
......@@ -1060,6 +1055,7 @@ cnt_lookup(struct sess *sp)
return (1);
}
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
......@@ -1067,6 +1063,14 @@ cnt_lookup(struct sess *sp)
if (oc->flags & OC_F_BUSY) {
sp->wrk->stats.cache_miss++;
if (sp->vary_l != NULL)
WS_ReleaseP(sp->ws, (void*)sp->vary_l);
else
WS_Release(sp->ws, 0);
sp->vary_b = NULL;
sp->vary_l = NULL;
sp->vary_e = NULL;
sp->objcore = oc;
sp->step = STP_MISS;
return (0);
......@@ -1076,6 +1080,11 @@ cnt_lookup(struct sess *sp)
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
sp->obj = o;
WS_Release(sp->ws, 0);
sp->vary_b = NULL;
sp->vary_l = NULL;
sp->vary_e = NULL;
if (oc->flags & OC_F_PASS) {
sp->wrk->stats.cache_hitpass++;
WSP(sp, SLT_HitPass, "%u", sp->obj->xid);
......
......@@ -176,9 +176,9 @@ vry_cmp(const uint8_t * const *v1, uint8_t * const *v2)
}
int
VRY_Match(const struct sess *sp, const uint8_t *vary)
VRY_Match(struct sess *sp, const uint8_t *vary)
{
uint8_t *vsp = sp->wrk->vary_b;
uint8_t *vsp = sp->vary_b;
char *h, *e;
unsigned lh, ln;
int i, retval = 1, oflo = 0;
......@@ -204,8 +204,8 @@ VRY_Match(const struct sess *sp, const uint8_t *vary)
/* Length of the entire new vary entry */
ln = 2 + vary[2] + 2 + (lh == 0xffff ? 0 : lh);
if (vsp + ln >= sp->wrk->vary_e) {
vsp = sp->wrk->vary_b;
if (vsp + ln >= sp->vary_e) {
vsp = sp->vary_b;
oflo = 1;
}
......@@ -213,7 +213,7 @@ VRY_Match(const struct sess *sp, const uint8_t *vary)
* We MUST have space for one entry and the end marker
* after it, which prevents old junk from confusing us
*/
assert(vsp + ln + 2 < sp->wrk->vary_e);
assert(vsp + ln + 2 < sp->vary_e);
vbe16enc(vsp, (uint16_t)lh);
memcpy(vsp + 2, vary + 2, vary[2] + 2);
......@@ -231,19 +231,19 @@ VRY_Match(const struct sess *sp, const uint8_t *vary)
vsp += vry_len(vsp);
vary += vry_len(vary);
}
if (vsp + 3 > sp->wrk->vary_e)
if (vsp + 3 > sp->vary_e)
oflo = 1;
if (oflo) {
/* XXX: Should log this */
vsp = sp->wrk->vary_b;
vsp = sp->vary_b;
}
vsp[0] = 0xff;
vsp[1] = 0xff;
vsp[2] = 0;
if (oflo)
sp->wrk->vary_l = NULL;
sp->vary_l = NULL;
else
sp->wrk->vary_l = vsp + 3;
sp->vary_l = vsp + 3;
return (retval);
}
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