[master] ed47f83 Move the busyobj allocation from cache_hash to cache_req_fsm Move the predictive vary from the req->ws to busyobj->ws.

Poul-Henning Kamp phk at varnish-cache.org
Mon Sep 3 11:03:52 CEST 2012


commit ed47f83d7eec2db21abbf59f8314be6c47ff3ea6
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Sep 3 09:03:14 2012 +0000

    Move the busyobj allocation from cache_hash to cache_req_fsm
    Move the predictive vary from the req->ws to busyobj->ws.

diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 932cb67..d0d987e 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -60,7 +60,6 @@
 
 
 #include "hash/hash_slinger.h"
-#include "vmb.h"
 #include "vsha256.h"
 
 static const struct hash_slinger *hash;
@@ -445,19 +444,6 @@ HSH_Lookup(struct req *req)
 	VTAILQ_INSERT_TAIL(&oh->objcs, oc, list);
 	/* NB: do not deref objhead the new object inherits our reference */
 	Lck_Unlock(&oh->mtx);
-
-	AZ(req->busyobj);
-	req->busyobj = VBO_GetBusyObj(wrk);
-	req->busyobj->refcount = 2;	/* One for req, one for FetchBody */
-
-	VRY_Validate(req->vary_b);
-	if (req->vary_l != NULL)
-		req->busyobj->vary = req->vary_b;
-	else
-		req->busyobj->vary = NULL;
-
-	VMB();
-	oc->busyobj = req->busyobj;
 	return (oc);
 }
 
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 18ca2e3..045dc6b 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -776,6 +776,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
 	struct objcore *oc;
 	struct object *o;
 	struct objhead *oh;
+	struct busyobj *bo;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
@@ -792,8 +793,8 @@ cnt_lookup(struct worker *wrk, struct req *req)
 		/*
 		 * We lost the session to a busy object, disembark the
 		 * worker thread.   We return to STP_LOOKUP when the busy
-		 * object has been unbusied, and still have the hash digest
-		 * around to do the lookup with.
+		 * object has been unbusied, and still have the objhead
+		 * around to restart the lookup with.
 		 */
 		return (2);
 	}
@@ -805,22 +806,28 @@ cnt_lookup(struct worker *wrk, struct req *req)
 
 	/* If we inserted a new object it's a miss */
 	if (oc->flags & OC_F_BUSY) {
-		CHECK_OBJ_NOTNULL(oc->busyobj, BUSYOBJ_MAGIC);
-		assert(oc->busyobj == req->busyobj);
-		wrk->stats.cache_miss++;
-
+		AZ(req->busyobj);
+		bo = VBO_GetBusyObj(wrk);
+		req->busyobj = bo;
+		/* One ref for req, one for FetchBody */
+		bo->refcount = 2;
+		VRY_Validate(req->vary_b);
 		if (req->vary_l != NULL) {
-			assert(oc->busyobj->vary == req->vary_b);
-			VRY_Validate(oc->busyobj->vary);
-			WS_ReleaseP(req->ws, (void*)req->vary_l);
-		} else {
-			AZ(oc->busyobj->vary);
-			WS_Release(req->ws, 0);
-		}
+			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;
+		wrk->stats.cache_miss++;
+
 		req->objcore = oc;
 		req->req_step = R_STP_MISS;
 		return (0);



More information about the varnish-commit mailing list