Skip to content

Commit

Permalink
Simple storage: Finalize busy object state also for ObjFreeObj()
Browse files Browse the repository at this point in the history
If oc->boc is not NULL for an ObjFreeObj() call, the stevedore
needs to finish any busy object transaction.

Fixes #3953
  • Loading branch information
nigoroll committed Jul 27, 2023
1 parent 3731e9f commit 3240185
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions bin/varnishd/storage/storage_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);
Expand Down Expand Up @@ -551,20 +574,14 @@ 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);
CHECK_OBJ_NOTNULL(boc, BOC_MAGIC);
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))
Expand Down

0 comments on commit 3240185

Please sign in to comment.