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

Properly book-end the predictive vary code.

parent ed47f83d
...@@ -987,6 +987,7 @@ struct vsb *VRY_Create(struct req *sp, const struct http *hp); ...@@ -987,6 +987,7 @@ struct vsb *VRY_Create(struct req *sp, const struct http *hp);
int VRY_Match(struct req *, const uint8_t *vary); int VRY_Match(struct req *, const uint8_t *vary);
void VRY_Validate(const uint8_t *vary); void VRY_Validate(const uint8_t *vary);
void VRY_Prep(struct req *); void VRY_Prep(struct req *);
void VRY_Finish(struct req *req, struct busyobj *bo);
/* cache_vcl.c */ /* cache_vcl.c */
void VCL_Init(void); void VCL_Init(void);
...@@ -1034,7 +1035,7 @@ void WS_ReleaseP(struct ws *ws, char *ptr); ...@@ -1034,7 +1035,7 @@ void WS_ReleaseP(struct ws *ws, char *ptr);
void WS_Assert(const struct ws *ws); void WS_Assert(const struct ws *ws);
void WS_Reset(struct ws *ws, char *p); void WS_Reset(struct ws *ws, char *p);
char *WS_Alloc(struct ws *ws, unsigned bytes); char *WS_Alloc(struct ws *ws, unsigned bytes);
char *WS_Copy(struct ws *ws, const char *str, int len); void *WS_Copy(struct ws *ws, const void *str, int len);
char *WS_Snapshot(struct ws *ws); char *WS_Snapshot(struct ws *ws);
/* rfc2616.c */ /* rfc2616.c */
......
...@@ -811,19 +811,7 @@ cnt_lookup(struct worker *wrk, struct req *req) ...@@ -811,19 +811,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
req->busyobj = bo; req->busyobj = bo;
/* One ref for req, one for FetchBody */ /* One ref for req, one for FetchBody */
bo->refcount = 2; bo->refcount = 2;
VRY_Validate(req->vary_b); VRY_Finish(req, bo);
if (req->vary_l != NULL) {
bo->vary = (void*)WS_Copy(bo->ws,
(void*)req->vary_b, req->vary_l - req->vary_b);
AN(bo->vary);
VRY_Validate(bo->vary);
} else
bo->vary = NULL;
WS_Release(req->ws, 0);
req->vary_b = NULL;
req->vary_l = NULL;
req->vary_e = NULL;
oc->busyobj = bo; oc->busyobj = bo;
wrk->stats.cache_miss++; wrk->stats.cache_miss++;
...@@ -840,10 +828,7 @@ cnt_lookup(struct worker *wrk, struct req *req) ...@@ -840,10 +828,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
req->obj = o; req->obj = o;
WS_Release(req->ws, 0); VRY_Finish(req, NULL);
req->vary_b = NULL;
req->vary_l = NULL;
req->vary_e = NULL;
if (oc->flags & OC_F_PASS) { if (oc->flags & OC_F_PASS) {
wrk->stats.cache_hitpass++; wrk->stats.cache_hitpass++;
......
...@@ -198,6 +198,31 @@ VRY_Prep(struct req *req) ...@@ -198,6 +198,31 @@ VRY_Prep(struct req *req)
req->vary_b[2] = '\0'; req->vary_b[2] = '\0';
} }
/**********************************************************************
* Finish predictive vary procssing
*/
void
VRY_Finish(struct req *req, struct busyobj *bo)
{
if (bo != NULL) {
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
VRY_Validate(req->vary_b);
if (req->vary_l != NULL) {
bo->vary = WS_Copy(bo->ws,
req->vary_b, req->vary_l - req->vary_b);
AN(bo->vary);
VRY_Validate(bo->vary);
} else
bo->vary = NULL;
}
WS_Release(req->ws, 0);
req->vary_b = NULL;
req->vary_l = NULL;
req->vary_e = NULL;
}
/********************************************************************** /**********************************************************************
* Match vary strings, and build a new cached string if possible. * Match vary strings, and build a new cached string if possible.
* *
......
...@@ -116,8 +116,8 @@ WS_Alloc(struct ws *ws, unsigned bytes) ...@@ -116,8 +116,8 @@ WS_Alloc(struct ws *ws, unsigned bytes)
return (r); return (r);
} }
char * void *
WS_Copy(struct ws *ws, const char *str, int len) WS_Copy(struct ws *ws, const void *str, int len)
{ {
char *r; char *r;
unsigned bytes; unsigned bytes;
......
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