[experimental-ims] bd0246a Edge closer to the new worldorder
Poul-Henning Kamp
phk at FreeBSD.org
Thu Dec 18 10:27:42 CET 2014
commit bd0246a0de438739a07bb1dca7f7badb67bc3bb5
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Mar 19 10:14:41 2012 +0000
Edge closer to the new worldorder
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 17f4f4d..f337f66 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1081,21 +1081,6 @@ Tadd(txt *t, const char *p, int l)
}
}
-static inline void
-AssertOCBusy(const struct objcore *oc)
-{
- AN(oc);
- AN (oc->flags & OC_F_BUSY);
- AN(oc->busyobj);
-}
-
-static inline void
-AssertObjCorePassOrBusy(const struct objcore *oc)
-{
- if (oc != NULL)
- AN (oc->flags & OC_F_BUSY);
-}
-
/*
* We want to cache the most recent timestamp in wrk->lastused to avoid
* extra timestamps in cache_pool.c. Hide this detail with a macro
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 30a797b..8b12807 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -215,7 +215,6 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req)
if (bo != NULL) {
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
AN(bo->do_stream);
- AssertObjCorePassOrBusy(req->obj->objcore);
}
req->res_mode = 0;
@@ -635,7 +634,6 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req)
switch (req->handling) {
case VCL_RET_DELIVER:
- AssertObjCorePassOrBusy(req->objcore);
sp->step = STP_PREPFETCH;
return (0);
default:
@@ -875,8 +873,6 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req)
RFC2616_Do_Cond(sp))
bo->do_stream = 0;
- AssertObjCorePassOrBusy(req->obj->objcore);
-
sp->step = STP_FETCHBODY;
return (0);
}
@@ -1136,6 +1132,9 @@ cnt_lookup(struct sess *sp, struct worker *wrk, struct req *req)
return (0);
}
+ /* We are not prepared to do streaming yet */
+ XXXAZ(req->busyobj);
+
o = oc_getobj(&wrk->stats, oc);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
req->obj = o;
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index 9d7136c..39ded77 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -224,7 +224,6 @@ EXP_Insert(struct object *o)
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
oc = o->objcore;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
- AssertOCBusy(oc);
HSH_Ref(oc);
assert(o->exp.entered != 0 && !isnan(o->exp.entered));
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 5406b2f..cab6273 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -40,6 +40,7 @@
#include "cache_backend.h"
#include "vcli_priv.h"
#include "vct.h"
+#include "vmb.h"
#include "vtcp.h"
static unsigned fetchfrag;
@@ -570,8 +571,6 @@ FetchBody(struct worker *wrk, void *priv)
if (bo->vfp == NULL)
bo->vfp = &vfp_nop;
- AssertObjCorePassOrBusy(obj->objcore);
-
AZ(bo->vgz_rx);
AZ(VTAILQ_FIRST(&obj->store));
@@ -681,6 +680,8 @@ FetchBody(struct worker *wrk, void *priv)
AN(obj->objcore->ban);
AZ(obj->ws_o->overflow);
HSH_Unbusy(&wrk->stats, obj->objcore);
+ obj->objcore->busyobj = NULL;
+ VMB();
}
/* XXX: Atomic assignment, needs volatile/membar ? */
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 978277a..09ee9f4 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -551,9 +551,7 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace)
/*---------------------------------------------------------------------
- * Kill a busy object we don't need anyway.
- * There may be sessions on the waiting list, so we cannot just blow
- * it out of the water.
+ * Kill a busy object we don't need and can't use.
*/
void
@@ -563,13 +561,14 @@ HSH_Drop(struct worker *wrk, struct object **oo)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
AN(oo);
CHECK_OBJ_NOTNULL(*oo, OBJECT_MAGIC);
- AssertObjCorePassOrBusy((*oo)->objcore);
(*oo)->exp.ttl = -1.;
- if ((*oo)->objcore != NULL) /* Pass has no objcore */
- HSH_Unbusy(&wrk->stats, (*oo)->objcore);
- (void)HSH_Deref(&wrk->stats, NULL, oo);
+ AZ(HSH_Deref(&wrk->stats, NULL, oo));
}
+/*---------------------------------------------------------------------
+ * Unbusy an objcore when the object is completely fetched.
+ */
+
void
HSH_Unbusy(struct dstat *ds, struct objcore *oc)
{
@@ -579,9 +578,8 @@ HSH_Unbusy(struct dstat *ds, struct objcore *oc)
oh = oc->objhead;
CHECK_OBJ(oh, OBJHEAD_MAGIC);
- AssertOCBusy(oc);
+ AN(oc->flags & OC_F_BUSY);
AN(oc->ban);
- assert(oc->refcnt > 0);
assert(oh->refcnt > 0);
/* XXX: pretouch neighbors on oh->objcs to prevent page-on under mtx */
@@ -591,13 +589,15 @@ HSH_Unbusy(struct dstat *ds, struct objcore *oc)
VTAILQ_REMOVE(&oh->objcs, oc, list);
VTAILQ_INSERT_HEAD(&oh->objcs, oc, list);
oc->flags &= ~OC_F_BUSY;
- oc->busyobj = NULL;
if (oh->waitinglist != NULL)
hsh_rush(ds, oh);
- AN(oc->ban);
Lck_Unlock(&oh->mtx);
}
+/*---------------------------------------------------------------------
+ * Gain a reference on an objcore
+ */
+
void
HSH_Ref(struct objcore *oc)
{
More information about the varnish-commit
mailing list