Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

Commit 465d472

Browse files
committed
cache_expire: Avoid double counting of OC_EF_REMOVE objects
When the exp_expire() finds the expired object also in the inbox, it would still count it as expired. We now avoid the double count by excluding objects with OC_EF_REMOVE set. And we also reduce traffic on the global counter by using a local variable for the loop.
1 parent d4db7a8 commit 465d472

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

bin/varnishd/cache/cache_expire.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ exp_expire(struct exp_priv *ep, struct exp_deref *deref, vtim_real now)
518518
{
519519
struct objcore *oc;
520520
vtim_real ret;
521+
unsigned n = 0;
521522

522523
CHECK_OBJ_NOTNULL(ep, EXP_PRIV_MAGIC);
523524

@@ -539,9 +540,11 @@ exp_expire(struct exp_priv *ep, struct exp_deref *deref, vtim_real now)
539540
break;
540541
}
541542

542-
VSC_C_main->n_expired++;
543+
n++;
543544

544545
if (oc->exp_flags & OC_EF_POSTED) {
546+
if (oc->exp_flags & OC_EF_REMOVE)
547+
n--;
545548
VSTAILQ_REMOVE(&ep->inbox, oc, objcore, exp_list);
546549
oc->exp_flags = 0;
547550
}
@@ -556,6 +559,7 @@ exp_expire(struct exp_priv *ep, struct exp_deref *deref, vtim_real now)
556559
assert(oc->timer_idx == VBH_NOIDX);
557560
}
558561
Lck_Unlock(&ep->mtx);
562+
VSC_C_main->n_expired += n;
559563

560564
return (ret);
561565
}

0 commit comments

Comments
 (0)