r5545 - trunk/varnish-cache/bin/varnishd
phk at varnish-cache.org
phk at varnish-cache.org
Tue Nov 16 11:28:02 CET 2010
Author: phk
Date: 2010-11-16 11:28:02 +0100 (Tue, 16 Nov 2010)
New Revision: 5545
Modified:
trunk/varnish-cache/bin/varnishd/cache_hash.c
Log:
If there are several grace-able objects, pick the least expired one.
Suggested by: Vincent Wells
Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-11-15 21:54:33 UTC (rev 5544)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-11-16 10:28:02 UTC (rev 5545)
@@ -359,6 +359,7 @@
struct objcore *oc;
struct objcore *busy_oc, *grace_oc;
struct object *o;
+ double grace_ttl;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
@@ -392,6 +393,7 @@
assert(oh->refcnt > 0);
busy_oc = NULL;
grace_oc = NULL;
+ grace_ttl = NAN;
VTAILQ_FOREACH(oc, &oh->objcs, list) {
/* Must be at least our own ref + the objcore we examine */
assert(oh->refcnt > 1);
@@ -420,9 +422,16 @@
if (o->ttl >= sp->t_req)
break;
- /* Remember any matching objects inside their grace period */
- if (o->ttl + HSH_Grace(o->grace) >= sp->t_req)
- grace_oc = oc;
+ /*
+ * Remember any matching objects inside their grace period
+ * and if there are several, use the least expired one.
+ */
+ if (o->ttl + HSH_Grace(o->grace) >= sp->t_req) {
+ if (grace_oc == NULL || grace_ttl < o->ttl) {
+ grace_oc = oc;
+ grace_ttl = o->ttl;
+ }
+ }
}
/*
More information about the varnish-commit
mailing list