From 3240185c31cfbf6d0c4bc8b3edd228a907439c95 Mon Sep 17 00:00:00 2001 From: Nils Goroll Date: Sun, 9 Jul 2023 14:07:52 +0200 Subject: [PATCH] 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 --- bin/varnishd/storage/storage_simple.c | 33 ++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 71f941e3484..c94dcccb455 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))