r494 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Tue Jul 18 15:19:55 CEST 2006
Author: phk
Date: 2006-07-18 15:19:55 +0200 (Tue, 18 Jul 2006)
New Revision: 494
Modified:
trunk/varnish-cache/bin/varnishd/cache_expire.c
Log:
Delete binheap root by it's index.
Expect a refcount of one (the one holding the object in the hash)
Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c 2006-07-18 13:18:50 UTC (rev 493)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2006-07-18 13:19:55 UTC (rev 494)
@@ -24,6 +24,7 @@
EXP_Insert(struct object *o)
{
+ assert(o->heap_idx == 0);
AZ(pthread_mutex_lock(&exp_mtx));
binheap_insert(exp_heap, o);
AZ(pthread_mutex_unlock(&exp_mtx));
@@ -32,6 +33,7 @@
void
EXP_TTLchange(struct object *o)
{
+ assert(o->heap_idx != 0);
AZ(pthread_mutex_lock(&exp_mtx));
binheap_delete(exp_heap, o->heap_idx);
binheap_insert(exp_heap, o);
@@ -54,17 +56,19 @@
t = time(NULL);
AZ(pthread_mutex_lock(&exp_mtx));
TAILQ_FOREACH(o, &exp_deathrow, deathrow) {
- if (o->ttl >= t)
+ if (o->ttl >= t) {
+ o = NULL;
break;
+ }
if (o->busy) {
VSL(SLT_Debug, 0,
"Grim Reaper: Busy object xid %u", o->xid);
continue;
}
- if (o->refcnt == 0)
+ if (o->refcnt == 1)
break;
}
- if (o == NULL || o->ttl >= t || o->refcnt > 0) {
+ if (o == NULL) {
AZ(pthread_mutex_unlock(&exp_mtx));
AZ(sleep(1));
continue;
@@ -103,7 +107,7 @@
AZ(sleep(1));
continue;
}
- binheap_delete(exp_heap, 0);
+ binheap_delete(exp_heap, o->heap_idx);
AZ(pthread_mutex_unlock(&exp_mtx));
VSL(SLT_ExpPick, 0, "%u", o->xid);
More information about the varnish-commit
mailing list