[master] 1732352 If the OC doesn't have a boc, don't lock unnecessarily lock the OH
Martin Blix Grydeland
martin at varnish-software.com
Tue Feb 23 17:44:46 CET 2016
commit 17323520af6afc72261fc43bdd7ded803497f8d6
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Tue Feb 23 14:39:41 2016 +0100
If the OC doesn't have a boc, don't lock unnecessarily lock the OH
The objcore won't gain a boc in a way that would call for locking the
OH when checking if it wasn't there in the first place. So if the
oc->boc is NULL, return early. This saves a mutex lock/unlock in the
common case.
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index c70ef7b..797677b 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -749,6 +749,8 @@ HSH_RefBoc(const struct objcore *oc)
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
oh = oc->objhead;
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
+ if (oc->boc == NULL)
+ return (NULL);
Lck_Lock(&oh->mtx);
assert(oc->refcnt > 0);
boc = oc->boc;
More information about the varnish-commit
mailing list