[master] ae83488d9 obj: Extract unlock step from boc notification

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Jul 7 08:08:06 UTC 2025


commit ae83488d909cab23f201b706a530d79a2fbc4fd9
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Jul 7 10:03:44 2025 +0200

    obj: Extract unlock step from boc notification
    
    The current usage of obj_boc_notify_Unlock() was always following a call
    to Lck_Lock(), and never in a context where the BOC mutex was already
    held.
    
    Conflating the broadcast and unlock operations prevents conditional
    notifications from the #4073 candidate.

diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index dcbb991b6..7e1625582 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -356,10 +356,9 @@ obj_extend_condwait(const struct objcore *oc)
 }
 
 // notify of an extension of the boc or state change
-//lint -sem(obj_boc_notify_Unlock, thread_unlock)
 
 static void
-obj_boc_notify_Unlock(struct boc *boc)
+obj_boc_notify(struct boc *boc)
 {
 	struct vai_qe *qe, *next;
 
@@ -375,7 +374,6 @@ obj_boc_notify_Unlock(struct boc *boc)
 		qe->cb(qe->hdl, qe->priv);
 		qe = next;
 	}
-	Lck_Unlock(&boc->mtx);
 }
 
 void
@@ -393,7 +391,8 @@ ObjExtend(struct worker *wrk, struct objcore *oc, ssize_t l, int final)
 		obj_extend_condwait(oc);
 		om->objextend(wrk, oc, l);
 		oc->boc->fetched_so_far += l;
-		obj_boc_notify_Unlock(oc->boc);
+		obj_boc_notify(oc->boc);
+		Lck_Unlock(&oc->boc->mtx);
 	}
 
 	assert(oc->boc->state < BOS_FINISHED);
@@ -510,7 +509,8 @@ ObjSetState(struct worker *wrk, const struct objcore *oc,
 
 	Lck_Lock(&oc->boc->mtx);
 	oc->boc->state = next;
-	obj_boc_notify_Unlock(oc->boc);
+	obj_boc_notify(oc->boc);
+	Lck_Unlock(&oc->boc->mtx);
 }
 
 /*====================================================================


More information about the varnish-commit mailing list