Commit beaa6999 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Fix expiry of non-instantiated objects.

Add test-case for same.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4197 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent f974f9e8
......@@ -262,7 +262,9 @@ exp_timer(struct sess *sp, void *priv)
continue;
}
/* It's time... */
CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
/* Remove from binheap */
assert(oc->timer_idx != BINHEAP_NOIDX);
......@@ -286,16 +288,19 @@ exp_timer(struct sess *sp, void *priv)
Lck_Unlock(&exp_mtx);
CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
if (!(oc->flags & OC_F_PERSISTENT)) {
o = oc->obj;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
WSL(sp->wrk, SLT_ExpKill, 0, "%u %d",
o->xid, (int)(o->ttl - t));
HSH_Deref(sp->wrk, &o);
} else {
WSL(sp->wrk, SLT_ExpKill, 0, "%u %d",
WSL(sp->wrk, SLT_ExpKill, 1, "%u %d",
o, (int)(oc->timer_when - t));
sp->objhead = oc->objhead;
sp->objcore = oc;
HSH_DerefObjCore(sp);
}
}
}
......
......@@ -406,6 +406,7 @@ HSH_Insert(const struct sess *sp)
/* XXX: Should this not be ..._HEAD now ? */
VTAILQ_INSERT_TAIL(&oh->objcs, oc, list);
/* NB: do not deref objhead the new object inherits our reference */
oc->objhead = oh;
Lck_Unlock(&oh->mtx);
sp->wrk->stats->n_object++;
return (oc);
......@@ -642,6 +643,7 @@ HSH_DerefObjCore(struct sess *sp)
Lck_Lock(&oh->mtx);
VTAILQ_REMOVE(&oh->objcs, oc, list);
sp->wrk->stats->n_object--;
Lck_Unlock(&oh->mtx);
assert(oh->refcnt > 0);
FREE_OBJ(oc);
......
# $Id$
test "Check expiry of non-instantiated object"
shell "rm -f /tmp/__v1/_.per"
server s1 {
rxreq
txresp -hdr "Foo: foo1"
} -start
varnish v1 \
-arg "-pdiag_bitmap=0x30000" \
-arg "-spersistent,/tmp/__v1/_.per,10m" \
-vcl+backend {
sub vcl_fetch {
set beresp.ttl = 3s;
}
} -start
client c1 {
txreq -url "/foo"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
expect resp.http.foo == "foo1"
} -run
varnish v1 -expect n_object == 1
varnish v1 -stop
server s1 -wait {
rxreq
txresp -hdr "Foo: foo2"
} -start
varnish v1 -start
delay 5
client c1 {
txreq -url "/foo"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
expect resp.http.foo == "foo2"
} -run
varnish v1 -expect n_object == 1
......@@ -29,6 +29,8 @@ varnish v1 -vcl {
}
varnish v1 -expect n_backend == 2
# give the expiry thread a chance to let go of its VCL
delay 2
varnish v1 -expect n_vcl == 3
......
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