[master] ba104c9 Move the abandon flag from busyobj to objcore

Poul-Henning Kamp phk at FreeBSD.org
Thu Jan 28 12:49:20 CET 2016


commit ba104c9249a51cad3e8917590a932a7c51dc9626
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jan 21 12:28:02 2016 +0000

    Move the abandon flag from busyobj to objcore

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index b080036..564023e 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -426,6 +426,7 @@ struct objcore {
 #define OC_F_BUSY		(1<<1)
 #define OC_F_PASS		(1<<2)
 #define OC_F_INCOMPLETE		(1<<3)
+#define OC_F_ABANDON		(1<<4)
 #define OC_F_PRIVATE		(1<<8)
 #define OC_F_FAILED		(1<<9)
 
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 84caa85..e4f8ea3 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -486,7 +486,7 @@ vbf_fetch_body_helper(struct busyobj *bo)
 		est = 0;
 
 	do {
-		if (bo->abandon) {
+		if (vfc->oc->flags & OC_F_ABANDON) {
 			/*
 			 * A pass object and delivery was terminated
 			 * We don't fail the fetch, in order for hit-for-pass
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 3f2d9d8..039c694 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -653,6 +653,24 @@ HSH_Complete(struct objcore *oc)
 }
 
 /*---------------------------------------------------------------------
+ * Abandon a fetch we will not need
+ */
+
+void
+HSH_Abandon(struct objcore *oc)
+{
+	struct objhead *oh;
+
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+	oh = oc->objhead;
+	CHECK_OBJ(oh, OBJHEAD_MAGIC);
+
+	Lck_Lock(&oh->mtx);
+	oc->flags |= OC_F_ABANDON;
+	Lck_Unlock(&oh->mtx);
+}
+
+/*---------------------------------------------------------------------
  * Unbusy an objcore when the object is completely fetched.
  */
 
@@ -724,7 +742,7 @@ HSH_RefBusy(const struct objcore *oc)
 	assert(oc->refcnt > 0);
 	boc = oc->boc;
 	CHECK_OBJ_ORNULL(boc, BOC_MAGIC);
-	if (boc != NULL && boc->state < BOS_FINISHED) 
+	if (boc != NULL && boc->state < BOS_FINISHED)
 		boc->refcount++;
 	else
 		boc = NULL;
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 115473a..b2ee4bb 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -208,8 +208,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
 
 	if (req->objcore->flags & (OC_F_PRIVATE | OC_F_PASS)) {
 		if (boc != NULL) {
-			CHECK_OBJ_NOTNULL(boc->busyobj, BUSYOBJ_MAGIC);
-			boc->busyobj->abandon = 1;
+			HSH_Abandon(req->objcore);
 			ObjWaitState(boc, BOS_FINISHED);
 		}
 		ObjSlim(wrk, req->objcore);
diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h
index 7001204..0451006 100644
--- a/bin/varnishd/hash/hash_slinger.h
+++ b/bin/varnishd/hash/hash_slinger.h
@@ -75,6 +75,7 @@ void HSH_config(const char *h_arg);
 struct boc *HSH_RefBusy(const struct objcore *);
 void HSH_DerefBusy(struct worker *wrk, struct objcore *);
 struct objcore *HSH_Private(struct worker *wrk, int wantboc);
+void HSH_Abandon(struct objcore *oc);
 
 #ifdef VARNISH_CACHE_CHILD
 
diff --git a/bin/varnishtest/tests/r01391.vtc b/bin/varnishtest/tests/r01391.vtc
index 3858558..9669e16 100644
--- a/bin/varnishtest/tests/r01391.vtc
+++ b/bin/varnishtest/tests/r01391.vtc
@@ -15,9 +15,7 @@ server s1 {
 	chunkedlen 0
 } -start
 
-varnish v1 -vcl+backend {
-} -start
-
+varnish v1 -vcl+backend { } -start
 
 client c1 {
 	txreq
diff --git a/include/tbl/bo_flags.h b/include/tbl/bo_flags.h
index fedde3f..06608e3 100644
--- a/include/tbl/bo_flags.h
+++ b/include/tbl/bo_flags.h
@@ -36,7 +36,6 @@ BO_FLAG(do_gunzip,	1, 1, "")
 BO_FLAG(do_stream,	1, 1, "")
 BO_FLAG(do_pass,	0, 0, "")
 BO_FLAG(uncacheable,	0, 0, "")
-BO_FLAG(abandon,	0, 0, "")
 BO_FLAG(is_gzip,	0, 0, "")
 BO_FLAG(is_gunzip,	0, 0, "")
 BO_FLAG(was_304,	1, 0, "")



More information about the varnish-commit mailing list