Commit 8b077038 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

If there are several grace-able objects, pick the least expired one.

Suggested by:	Vincent Wells


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5545 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 470c76a1
......@@ -359,6 +359,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
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 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
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 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
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;
}
}
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment