[master] 27167c1f8 obj: Return BOC state reached from ObjWaitState()
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon Oct 27 14:09:05 UTC 2025
commit 27167c1f809ab7af50d334dfa441a7dfef040f61
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Wed Oct 1 12:54:10 2025 +0200
obj: Return BOC state reached from ObjWaitState()
This will allow safe checks related to BOC states that are not guarded
by the BOC lock.
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index 804c226aa..6cf110300 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -524,9 +524,10 @@ ObjSetState(struct worker *wrk, struct objcore *oc, enum boc_state_e next,
/*====================================================================
*/
-void
+enum boc_state_e
ObjWaitState(const struct objcore *oc, enum boc_state_e want)
{
+ enum boc_state_e got;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
CHECK_OBJ_NOTNULL(oc->boc, BOC_MAGIC);
@@ -540,7 +541,10 @@ ObjWaitState(const struct objcore *oc, enum boc_state_e want)
break;
(void)Lck_CondWait(&oc->boc->cond, &oc->boc->mtx);
}
+ got = oc->boc->state;
Lck_Unlock(&oc->boc->mtx);
+
+ return (got);
}
/*====================================================================
diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
index 56ce1c14b..a2edf2083 100644
--- a/bin/varnishd/cache/cache_varnishd.h
+++ b/bin/varnishd/cache/cache_varnishd.h
@@ -346,7 +346,7 @@ uint64_t ObjWaitExtend(const struct worker *, const struct objcore *,
uint64_t l, enum boc_state_e *statep);
void ObjSetState(struct worker *, struct objcore *, enum boc_state_e next,
unsigned broadcast);
-void ObjWaitState(const struct objcore *, enum boc_state_e want);
+enum boc_state_e ObjWaitState(const struct objcore *, enum boc_state_e want);
void ObjTouch(struct worker *, struct objcore *, vtim_real now);
void ObjFreeObj(struct worker *, struct objcore *);
void ObjSlim(struct worker *, struct objcore *);
More information about the varnish-commit
mailing list