Commit 709f71ab authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

hash: A purged object didn't get a chance to expire

So the n_expired, n_purges and n_obj_purged counters should reflect
that. Likewise, it shouldn't be logged as "EXP_Expired".
parent e3303ad3
...@@ -674,10 +674,12 @@ HSH_Purge(struct worker *wrk, struct objhead *oh, vtim_real ttl_now, ...@@ -674,10 +674,12 @@ HSH_Purge(struct worker *wrk, struct objhead *oh, vtim_real ttl_now,
{ {
struct objcore *oc, *oc_nows[2], **ocp; struct objcore *oc, *oc_nows[2], **ocp;
unsigned i, j, n, n_max, total = 0; unsigned i, j, n, n_max, total = 0;
int is_purge;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
is_purge = (ttl == 0 && grace == 0 && keep == 0);
n_max = WS_ReserveLumps(wrk->aws, sizeof *ocp); n_max = WS_ReserveLumps(wrk->aws, sizeof *ocp);
if (n_max < 2) { if (n_max < 2) {
/* No space on the workspace. Give it a stack buffer of 2 /* No space on the workspace. Give it a stack buffer of 2
...@@ -740,7 +742,10 @@ HSH_Purge(struct worker *wrk, struct objhead *oh, vtim_real ttl_now, ...@@ -740,7 +742,10 @@ HSH_Purge(struct worker *wrk, struct objhead *oh, vtim_real ttl_now,
} }
for (i = 0; i < j; i++) { for (i = 0; i < j; i++) {
CHECK_OBJ_NOTNULL(ocp[i], OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(ocp[i], OBJCORE_MAGIC);
EXP_Rearm(ocp[i], ttl_now, ttl, grace, keep); if (is_purge)
EXP_Remove(ocp[i]);
else
EXP_Rearm(ocp[i], ttl_now, ttl, grace, keep);
(void)HSH_DerefObjCore(wrk, &ocp[i], 0); (void)HSH_DerefObjCore(wrk, &ocp[i], 0);
AZ(ocp[i]); AZ(ocp[i]);
total++; total++;
...@@ -765,7 +770,8 @@ HSH_Purge(struct worker *wrk, struct objhead *oh, vtim_real ttl_now, ...@@ -765,7 +770,8 @@ HSH_Purge(struct worker *wrk, struct objhead *oh, vtim_real ttl_now,
} }
WS_Release(wrk->aws, 0); WS_Release(wrk->aws, 0);
Pool_PurgeStat(total); if (is_purge)
Pool_PurgeStat(total);
return (total); return (total);
} }
......
...@@ -33,3 +33,11 @@ client c1 { ...@@ -33,3 +33,11 @@ client c1 {
expect resp.http.foo == 2 expect resp.http.foo == 2
} -run } -run
varnish v1 -vsl_catchup
varnish v1 -expect MAIN.n_purges == 1
varnish v1 -expect MAIN.n_obj_purged == 1
# NB: a purge used to increase n_expired
varnish v1 -expect MAIN.n_expired == 0
...@@ -21,7 +21,7 @@ varnish v1 -vcl+backend { ...@@ -21,7 +21,7 @@ varnish v1 -vcl+backend {
varnish v1 -cliok "param.set timeout_idle 2" varnish v1 -cliok "param.set timeout_idle 2"
logexpect l0 -v v1 -g raw { logexpect l0 -v v1 -g raw {
expect * 0 ExpKill "EXP_Expired x=1002" expect * 0 ExpKill "EXP_Removed x=1002"
} -start } -start
logexpect l2 -v v1 -g raw { logexpect l2 -v v1 -g raw {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment