r4513 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Mon Feb 1 07:48:16 CET 2010
Author: phk
Date: 2010-02-01 07:48:16 +0100 (Mon, 01 Feb 2010)
New Revision: 4513
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_expire.c
trunk/varnish-cache/bin/varnishd/cache_hash.c
trunk/varnish-cache/bin/varnishd/cache_panic.c
trunk/varnish-cache/bin/varnishd/stevedore.c
trunk/varnish-cache/bin/varnishd/storage_persistent.c
Log:
Lift the object refcount up to the objcore structure.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2010-01-29 12:16:31 UTC (rev 4512)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2010-02-01 06:48:16 UTC (rev 4513)
@@ -284,6 +284,7 @@
struct objcore {
unsigned magic;
#define OBJCORE_MAGIC 0x4d301302
+ unsigned refcnt;
struct object *obj;
struct objhead *objhead;
double timer_when;
@@ -315,7 +316,6 @@
struct object {
unsigned magic;
#define OBJECT_MAGIC 0x32851d42
- unsigned refcnt;
unsigned xid;
struct storage *objstore;
struct objcore *objcore;
Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c 2010-01-29 12:16:31 UTC (rev 4512)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2010-02-01 06:48:16 UTC (rev 4513)
@@ -345,7 +345,7 @@
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
if (oc->timer_idx == BINHEAP_NOIDX) /* exp_timer has it */
continue;
- if (oc->obj->refcnt == 1)
+ if (oc->refcnt == 1)
break;
}
if (oc != NULL) {
Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-01-29 12:16:31 UTC (rev 4512)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-02-01 06:48:16 UTC (rev 4513)
@@ -294,6 +294,7 @@
/* Insert (precreated) objcore in objecthead */
oc = w->nobjcore;
w->nobjcore = NULL;
+ oc->refcnt = 1;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AZ(oc->flags & OC_F_BUSY);
@@ -409,7 +410,7 @@
assert(oc->objhead == oh);
/* We found an object we like */
- o->refcnt++;
+ oc->refcnt++;
if (o->hits < INT_MAX)
o->hits++;
assert(oh->refcnt > 1);
@@ -437,6 +438,7 @@
oc = w->nobjcore;
w->nobjcore = NULL;
AN(oc->flags & OC_F_BUSY);
+ oc->refcnt = 1;
/* XXX: Should this not be ..._HEAD now ? */
VTAILQ_INSERT_TAIL(&oh->objcs, oc, list);
@@ -474,6 +476,12 @@
}
}
+/**********************************************************************
+ * 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.
+ */
+
void
HSH_Drop(struct sess *sp)
{
@@ -482,8 +490,8 @@
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
o = sp->obj;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- assert(o->refcnt > 0);
if (o->objcore != NULL) { /* Pass has no objcore */
+ assert(o->objcore->refcnt > 0);
AN(ObjIsBusy(o));
o->ttl = 0;
}
@@ -509,7 +517,7 @@
AN(ObjIsBusy(o));
AN(o->ban);
assert(o->objcore->obj == o);
- assert(o->refcnt > 0);
+ assert(o->objcore->refcnt > 0);
assert(oh->refcnt > 0);
if (o->ws_o->overflow)
sp->wrk->stats.n_objoverflow++;
@@ -534,8 +542,8 @@
oh = o->objcore->objhead;
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
Lck_Lock(&oh->mtx);
- assert(o->refcnt > 0);
- o->refcnt++;
+ assert(o->objcore->refcnt > 0);
+ o->objcore->refcnt++;
Lck_Unlock(&oh->mtx);
}
@@ -593,7 +601,7 @@
if (oc2 != NULL && oc2->flags & OC_F_PERSISTENT)
SMP_Fixup(sp, oh, oc2);
if (oc2 != NULL)
- oc2->obj->refcnt++;
+ oc2->refcnt++;
Lck_Unlock(&oh->mtx);
*oc = oc2;
}
@@ -612,8 +620,7 @@
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
oc = o->objcore;
if (oc == NULL) {
- assert(o->refcnt > 0);
- r = --o->refcnt;
+ r = 0;
oh = NULL;
} else {
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
@@ -622,8 +629,8 @@
Lck_Lock(&oh->mtx);
assert(oh->refcnt > 0);
- assert(o->refcnt > 0);
- r = --o->refcnt;
+ assert(oc->refcnt > 0);
+ r = --oc->refcnt;
if (!r)
VTAILQ_REMOVE(&oh->objcs, oc, list);
hsh_rush(oh);
Modified: trunk/varnish-cache/bin/varnishd/cache_panic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_panic.c 2010-01-29 12:16:31 UTC (rev 4512)
+++ trunk/varnish-cache/bin/varnishd/cache_panic.c 2010-02-01 06:48:16 UTC (rev 4513)
@@ -163,7 +163,7 @@
const struct storage *st;
vsb_printf(vsp, " obj = %p {\n", o);
- vsb_printf(vsp, " refcnt = %u, xid = %u,\n", o->refcnt, o->xid);
+ vsb_printf(vsp, " xid = %u,\n", o->xid);
pan_ws(o->ws_o, 4);
pan_http("obj", o->http, 4);
vsb_printf(vsp, " len = %u,\n", o->len);
Modified: trunk/varnish-cache/bin/varnishd/stevedore.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.c 2010-01-29 12:16:31 UTC (rev 4512)
+++ trunk/varnish-cache/bin/varnishd/stevedore.c 2010-02-01 06:48:16 UTC (rev 4513)
@@ -101,7 +101,6 @@
http_Setup(o->http, o->ws_o);
o->http->magic = HTTP_MAGIC;
- o->refcnt = 1;
o->grace = NAN;
o->entered = NAN;
VTAILQ_INIT(&o->store);
Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c 2010-01-29 12:16:31 UTC (rev 4512)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c 2010-02-01 06:48:16 UTC (rev 4513)
@@ -672,7 +672,6 @@
oc->flags &= ~OC_F_PERSISTENT;
/* refcnt is one because the object is in the hash */
- oc->obj->refcnt = 1;
oc->obj->objcore = oc;
oc->obj->ban = oc->ban;
More information about the varnish-commit
mailing list