[master] c4b7322 Properly book-end the predictive vary code.
Poul-Henning Kamp
phk at varnish-cache.org
Mon Sep 3 11:43:17 CEST 2012
commit c4b7322c92c95b662f9853d4a31a389a790dd743
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Sep 3 09:42:54 2012 +0000
Properly book-end the predictive vary code.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index c92a2d0..15db84c 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -987,6 +987,7 @@ struct vsb *VRY_Create(struct req *sp, const struct http *hp);
int VRY_Match(struct req *, const uint8_t *vary);
void VRY_Validate(const uint8_t *vary);
void VRY_Prep(struct req *);
+void VRY_Finish(struct req *req, struct busyobj *bo);
/* cache_vcl.c */
void VCL_Init(void);
@@ -1034,7 +1035,7 @@ void WS_ReleaseP(struct ws *ws, char *ptr);
void WS_Assert(const struct ws *ws);
void WS_Reset(struct ws *ws, char *p);
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);
/* rfc2616.c */
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 045dc6b..9f996c3 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -811,19 +811,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
req->busyobj = bo;
/* One ref for req, one for FetchBody */
bo->refcount = 2;
- VRY_Validate(req->vary_b);
- 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;
+ VRY_Finish(req, bo);
oc->busyobj = bo;
wrk->stats.cache_miss++;
@@ -840,10 +828,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
req->obj = o;
- WS_Release(req->ws, 0);
- req->vary_b = NULL;
- req->vary_l = NULL;
- req->vary_e = NULL;
+ VRY_Finish(req, NULL);
if (oc->flags & OC_F_PASS) {
wrk->stats.cache_hitpass++;
diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c
index 5f508d2..d4319b2 100644
--- a/bin/varnishd/cache/cache_vary.c
+++ b/bin/varnishd/cache/cache_vary.c
@@ -199,6 +199,31 @@ VRY_Prep(struct req *req)
}
/**********************************************************************
+ * 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.
*
* Return zero if there is certainly no match.
diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c
index 6c08422..31738e3 100644
--- a/bin/varnishd/cache/cache_ws.c
+++ b/bin/varnishd/cache/cache_ws.c
@@ -116,8 +116,8 @@ WS_Alloc(struct ws *ws, unsigned bytes)
return (r);
}
-char *
-WS_Copy(struct ws *ws, const char *str, int len)
+void *
+WS_Copy(struct ws *ws, const void *str, int len)
{
char *r;
unsigned bytes;
More information about the varnish-commit
mailing list