r5552 - trunk/varnish-cache/bin/varnishd
phk at varnish-cache.org
phk at varnish-cache.org
Wed Nov 17 18:27:15 CET 2010
Author: phk
Date: 2010-11-17 18:27:15 +0100 (Wed, 17 Nov 2010)
New Revision: 5552
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_ban.c
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_esi.c
trunk/varnish-cache/bin/varnishd/cache_expire.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_hash.c
trunk/varnish-cache/bin/varnishd/storage_persistent.c
Log:
Move the ban pointer to objcore, as long planned.
Clean up assert for proper use of busy flag
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2010-11-17 13:06:26 UTC (rev 5551)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2010-11-17 17:27:15 UTC (rev 5552)
@@ -383,7 +383,6 @@
unsigned char *vary;
double ban_t;
- struct ban *ban; /* XXX --> objcore */
unsigned response;
unsigned cacheable;
@@ -549,7 +548,7 @@
void BAN_Insert(struct ban *b);
void BAN_Init(void);
void BAN_NewObj(struct object *o);
-void BAN_DestroyObj(struct object *o);
+void BAN_DestroyObj(struct objcore *oc);
int BAN_CheckObject(struct object *o, const struct sess *sp);
void BAN_Reload(double t0, unsigned flags, const char *ban);
struct ban *BAN_TailRef(void);
@@ -832,10 +831,16 @@
}
}
-static inline unsigned
-ObjIsBusy(const struct object *o)
+static inline void
+AssertObjBusy(const struct object *o)
{
- CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- CHECK_OBJ_NOTNULL(o->objcore, OBJCORE_MAGIC);
- return (o->objcore->flags & OC_F_BUSY);
+ AN(o->objcore);
+ AN (o->objcore->flags & OC_F_BUSY);
}
+
+static inline void
+AssertObjPassOrBusy(const struct object *o)
+{
+ if (o->objcore != NULL)
+ AN (o->objcore->flags & OC_F_BUSY);
+}
Modified: trunk/varnish-cache/bin/varnishd/cache_ban.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_ban.c 2010-11-17 13:06:26 UTC (rev 5551)
+++ trunk/varnish-cache/bin/varnishd/cache_ban.c 2010-11-17 17:27:15 UTC (rev 5552)
@@ -359,16 +359,18 @@
void
BAN_NewObj(struct object *o)
{
+ struct objcore *oc;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- CHECK_OBJ_NOTNULL(o->objcore, OBJCORE_MAGIC);
- AZ(o->ban);
+ oc = o->objcore;
+ CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+ AZ(oc->ban);
Lck_Lock(&ban_mtx);
- o->ban = ban_start;
+ oc->ban = ban_start;
ban_start->refcount++;
- VTAILQ_INSERT_TAIL(&ban_start->objcore, o->objcore, ban_list);
+ VTAILQ_INSERT_TAIL(&ban_start->objcore, oc, ban_list);
Lck_Unlock(&ban_mtx);
- o->ban_t = o->ban->t0;
+ o->ban_t = oc->ban->t0;
}
static struct ban *
@@ -389,19 +391,19 @@
}
void
-BAN_DestroyObj(struct object *o)
+BAN_DestroyObj(struct objcore *oc)
{
struct ban *b;
- CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- if (o->ban == NULL)
+ CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+ if (oc->ban == NULL)
return;
- CHECK_OBJ_NOTNULL(o->ban, BAN_MAGIC);
+ CHECK_OBJ_NOTNULL(oc->ban, BAN_MAGIC);
Lck_Lock(&ban_mtx);
- assert(o->ban->refcount > 0);
- o->ban->refcount--;
- VTAILQ_REMOVE(&o->ban->objcore, o->objcore, ban_list);
- o->ban = NULL;
+ assert(oc->ban->refcount > 0);
+ oc->ban->refcount--;
+ VTAILQ_REMOVE(&oc->ban->objcore, oc, ban_list);
+ oc->ban = NULL;
/* Attempt to purge last ban entry */
b = BAN_CheckLast();
@@ -415,17 +417,20 @@
ban_check_object(struct object *o, const struct sess *sp, int has_req)
{
struct ban *b;
+ struct objcore *oc;
struct ban_test *bt;
struct ban * volatile b0;
unsigned tests;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- CHECK_OBJ_NOTNULL(o->ban, BAN_MAGIC);
+ oc = o->objcore;
+ CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+ CHECK_OBJ_NOTNULL(oc->ban, BAN_MAGIC);
b0 = ban_start;
- if (b0 == o->ban)
+ if (b0 == oc->ban)
return (0);
/*
@@ -434,7 +439,7 @@
* inspect the list past that ban.
*/
tests = 0;
- for (b = b0; b != o->ban; b = VTAILQ_NEXT(b, list)) {
+ for (b = b0; b != oc->ban; b = VTAILQ_NEXT(b, list)) {
if (b->flags & BAN_F_GONE)
continue;
if (!has_req && (b->flags & BAN_F_REQ))
@@ -449,26 +454,26 @@
}
Lck_Lock(&ban_mtx);
- o->ban->refcount--;
- VTAILQ_REMOVE(&o->ban->objcore, o->objcore, ban_list);
- if (b == o->ban) { /* not banned */
- VTAILQ_INSERT_TAIL(&b0->objcore, o->objcore, ban_list);
+ oc->ban->refcount--;
+ VTAILQ_REMOVE(&oc->ban->objcore, oc, ban_list);
+ if (b == oc->ban) { /* not banned */
+ VTAILQ_INSERT_TAIL(&b0->objcore, oc, ban_list);
b0->refcount++;
}
VSC_main->n_purge_obj_test++;
VSC_main->n_purge_re_test += tests;
Lck_Unlock(&ban_mtx);
- if (b == o->ban) { /* not banned */
- o->ban = b0;
- o->ban_t = o->ban->t0;
- oc_updatemeta(o->objcore);
+ if (b == oc->ban) { /* not banned */
+ oc->ban = b0;
+ o->ban_t = oc->ban->t0;
+ oc_updatemeta(oc);
return (0);
} else {
o->ttl = 0;
o->cacheable = 0;
- o->ban = NULL;
- oc_updatemeta(o->objcore);
+ oc->ban = NULL;
+ oc_updatemeta(oc);
/* BAN also changed, but that is not important any more */
WSP(sp, SLT_ExpBan, "%u was banned", o->xid);
EXP_Rearm(o);
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2010-11-17 13:06:26 UTC (rev 5551)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2010-11-17 17:27:15 UTC (rev 5552)
@@ -671,7 +671,8 @@
sp->obj->cacheable = 1;
if (sp->wrk->cacheable) {
EXP_Insert(sp->obj);
- AN(sp->obj->ban);
+ AN(sp->obj->objcore);
+ AN(sp->obj->objcore->ban);
HSH_Unbusy(sp);
}
sp->acct_tmp.fetch++;
Modified: trunk/varnish-cache/bin/varnishd/cache_esi.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_esi.c 2010-11-17 13:06:26 UTC (rev 5551)
+++ trunk/varnish-cache/bin/varnishd/cache_esi.c 2010-11-17 17:27:15 UTC (rev 5552)
@@ -704,8 +704,7 @@
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
- if (sp->obj->objcore != NULL) /* Pass has no objcore */
- AN(ObjIsBusy(sp->obj));
+ AssertObjPassOrBusy(sp->obj);
if (VTAILQ_EMPTY(&sp->obj->store))
return;
Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c 2010-11-17 13:06:26 UTC (rev 5551)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2010-11-17 17:27:15 UTC (rev 5552)
@@ -125,10 +125,10 @@
struct lru *lru;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- CHECK_OBJ_NOTNULL(o->objcore, OBJCORE_MAGIC);
- AN(ObjIsBusy(o));
+ oc = o->objcore;
+ CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+ AssertObjBusy(o);
assert(o->cacheable);
- oc = o->objcore;
HSH_Ref(oc);
assert(o->entered != 0 && !isnan(o->entered));
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2010-11-17 13:06:26 UTC (rev 5551)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2010-11-17 17:27:15 UTC (rev 5552)
@@ -469,8 +469,7 @@
/* We use the unmodified headers */
hp = sp->wrk->beresp1;
AN(sp->director);
- if (sp->obj->objcore != NULL) /* pass has no objcore */
- AN(ObjIsBusy(sp->obj));
+ AssertObjPassOrBusy(sp->obj);
/*
* Determine if we have a body or not
Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-11-17 13:06:26 UTC (rev 5551)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-11-17 17:27:15 UTC (rev 5552)
@@ -127,7 +127,7 @@
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj->objstore, STORAGE_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj->objstore->stevedore, STEVEDORE_MAGIC);
- AN(ObjIsBusy(sp->obj));
+ AssertObjBusy(sp->obj);
if (sp->obj->objstore->stevedore->object != NULL)
sp->obj->objstore->stevedore->object(sp);
}
@@ -605,12 +605,9 @@
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
o = sp->obj;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- if (o->objcore != NULL) { /* Pass has no objcore */
- assert(o->objcore->refcnt > 0);
- AN(ObjIsBusy(o));
- o->ttl = 0;
- }
+ AssertObjPassOrBusy(o);
o->cacheable = 0;
+ o->ttl = 0;
if (o->objcore != NULL) /* Pass has no objcore */
HSH_Unbusy(sp);
(void)HSH_Deref(sp->wrk, NULL, &sp->obj);
@@ -621,18 +618,20 @@
{
struct object *o;
struct objhead *oh;
+ struct objcore *oc;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
o = sp->obj;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- CHECK_OBJ_NOTNULL(o->objcore, OBJCORE_MAGIC);
- oh = o->objcore->objhead;
+ oc = o->objcore;
+ CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+ oh = oc->objhead;
CHECK_OBJ(oh, OBJHEAD_MAGIC);
- AN(ObjIsBusy(o));
- AN(o->ban);
- assert(oc_getobj(sp->wrk, o->objcore) == o);
- assert(o->objcore->refcnt > 0);
+ AssertObjBusy(o);
+ AN(oc->ban);
+ assert(oc_getobj(sp->wrk, oc) == o);
+ assert(oc->refcnt > 0);
assert(oh->refcnt > 0);
if (o->ws_o->overflow)
sp->wrk->stats.n_objoverflow++;
@@ -642,9 +641,9 @@
Lck_Lock(&oh->mtx);
assert(oh->refcnt > 0);
- o->objcore->flags &= ~OC_F_BUSY;
+ oc->flags &= ~OC_F_BUSY;
hsh_rush(oh);
- AN(o->ban);
+ AN(oc->ban);
Lck_Unlock(&oh->mtx);
}
@@ -715,9 +714,10 @@
}
if (o != NULL) {
- if (oc != NULL)
- BAN_DestroyObj(o);
- AZ(o->ban);
+ if (oc != NULL) {
+ BAN_DestroyObj(oc);
+ AZ(oc->ban);
+ }
DSL(0x40, SLT_Debug, 0, "Object %u workspace min free %u",
o->xid, WS_Free(o->ws_o));
Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c 2010-11-17 13:06:26 UTC (rev 5551)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c 2010-11-17 17:27:15 UTC (rev 5552)
@@ -678,7 +678,6 @@
/* refcnt is one because the object is in the hash */
o->objcore = oc;
- o->ban = oc->ban;
sg->nfixed++;
wrk->stats.n_object++;
More information about the varnish-commit
mailing list