Query about HSH_EXPBUSY & HSH_EXP in HSH_Lookup
Arvind Narayanan
arvind at cs.umn.edu
Thu Feb 1 20:46:45 UTC 2018
Hi,
I was trying to understand the function
enum lookup_e
HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
int always_insert)
located in bin/varnishd/cache/cache_hash.c
My understanding is, if the lookedup-object in the cache is expired, the
code seems to look if the object is busy or not and accordingly returns
HSH_EXPBUSY or HSH_BUSY.
lines 474 to 501 in cache_hash.c
if (exp_oc != NULL && exp_oc->flags & OC_F_PASS) {
wrk->stats->cache_hitmiss++;
VSLb(req->vsl, SLT_HitMiss, "%u %.6f", ObjGetXID(wrk, exp_oc),
EXP_Dttl(req, exp_oc));
exp_oc = NULL;
busy_found = 0;
}
if (exp_oc != NULL) {
assert(oh->refcnt > 1);
assert(exp_oc->objhead == oh);
exp_oc->refcnt++;
if (!busy_found) {
*bocp = hsh_insert_busyobj(wrk, oh);
retval = HSH_EXPBUSY;
} else {
AZ(req->hash_ignore_busy);
retval = HSH_EXP;
}
if (exp_oc->hits < LONG_MAX)
exp_oc->hits++;
Lck_Unlock(&oh->mtx);
if (retval == HSH_EXP)
assert(HSH_DerefObjHead(wrk, &oh));
*ocp = exp_oc;
return (retval);
}
if (!busy_found) {
/* Insert objcore in objecthead and release mutex */
*bocp = hsh_insert_busyobj(wrk, oh);
/* NB: no deref of objhead, new object inherits reference */
Lck_Unlock(&oh->mtx);
return (HSH_MISS);
}
If busy, is the variable busy_found set to 0 or 1? For expired objects, it
looks like if it is not busy, then you set the return value to HSH_EXPBUSY,
shouldn't it be HSH_EXP? Can anyone help me understand this piece of code?
Because below, the code returns HSH_MISS
Thanks,
Arvind
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20180201/c5b89e1f/attachment.html>
More information about the varnish-misc
mailing list