[master] 7ef1f9472 Simple storage: Finalize busy object state also for ObjFreeObj()
Nils Goroll
nils.goroll at uplex.de
Wed Aug 23 09:49:03 UTC 2023
commit 7ef1f94720a45433a8144d70902b7e2b1356868e
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Sun Jul 9 14:07:52 2023 +0200
Simple storage: Finalize busy object state also for ObjFreeObj()
If oc->boc is not NULL for an ObjFreeObj() call, the stevedore
needs to finish any busy object transaction.
Fixes #3953
diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c
index 71f941e34..c94dcccb4 100644
--- a/bin/varnishd/storage/storage_simple.c
+++ b/bin/varnishd/storage/storage_simple.c
@@ -249,6 +249,27 @@ sml_slim(struct worker *wrk, struct objcore *oc)
}
}
+static void
+sml_bocfini(const struct stevedore *stv, struct boc *boc)
+{
+ struct storage *st;
+
+ CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
+ CHECK_OBJ_NOTNULL(boc, BOC_MAGIC);
+
+ if (boc->stevedore_priv == NULL)
+ return;
+
+ /* Free any leftovers from Trim */
+ TAKE_OBJ_NOTNULL(st, &boc->stevedore_priv, STORAGE_MAGIC);
+ sml_stv_free(stv, st);
+}
+
+/*
+ * called in two cases:
+ * - oc->boc == NULL: cache object on LRU freed
+ * - oc->boc != NULL: cache object replaced for backend error
+ */
static void v_matchproto_(objfree_f)
sml_objfree(struct worker *wrk, struct objcore *oc)
{
@@ -267,7 +288,9 @@ sml_objfree(struct worker *wrk, struct objcore *oc)
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
FINI_OBJ(o);
- if (oc->boc == NULL && stv->lru != NULL)
+ if (oc->boc != NULL)
+ sml_bocfini(stv, oc->boc);
+ else if (stv->lru != NULL)
LRU_Remove(oc);
sml_stv_free(stv, st);
@@ -551,7 +574,6 @@ static void v_matchproto_(objbocdone_f)
sml_bocdone(struct worker *wrk, struct objcore *oc, struct boc *boc)
{
const struct stevedore *stv;
- struct storage *st;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
@@ -559,12 +581,7 @@ sml_bocdone(struct worker *wrk, struct objcore *oc, struct boc *boc)
stv = oc->stobj->stevedore;
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
- if (boc->stevedore_priv != NULL) {
- /* Free any leftovers from Trim */
- CAST_OBJ_NOTNULL(st, boc->stevedore_priv, STORAGE_MAGIC);
- boc->stevedore_priv = NULL;
- sml_stv_free(stv, st);
- }
+ sml_bocfini(stv, boc);
if (stv->lru != NULL) {
if (isnan(wrk->lastused))
More information about the varnish-commit
mailing list