[master] 2e22c1c I broke discarding old objects when they have been replaced in c709e110d4e1c70052caae366b8777e87490a8e0.
Poul-Henning Kamp
phk at FreeBSD.org
Mon Sep 21 12:19:52 CEST 2015
commit 2e22c1c3817ffc106db1903941661f5873f612a9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Sep 21 10:19:01 2015 +0000
I broke discarding old objects when they have been replaced
in c709e110d4e1c70052caae366b8777e87490a8e0.
Spotted by: Martin
Test-case by: Martin
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 262d791..8ee198b 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -186,7 +186,8 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo)
} else
AZ(bo->stale_oc);
- if (bo->stale_oc != NULL) {
+ if (bo->stale_oc != NULL &&
+ ObjCheckFlag(bo->wrk, bo->stale_oc, OF_IMSCAND)) {
q = HTTP_GetHdrPack(bo->wrk, bo->stale_oc, H_Last_Modified);
if (q != NULL)
http_PrintfHeader(bo->bereq0,
@@ -393,7 +394,8 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
AZ(bo->was_304);
if (http_IsStatus(bo->beresp, 304)) {
- if (bo->stale_oc != NULL) {
+ if (bo->stale_oc != NULL &&
+ ObjCheckFlag(bo->wrk, bo->stale_oc, OF_IMSCAND)) {
if (ObjCheckFlag(bo->wrk, bo->stale_oc, OF_CHGGZIP)) {
/*
* If we changed the gzip status of the object
@@ -904,12 +906,14 @@ vbf_fetch_thread(struct worker *wrk, void *priv)
bo->wrk = wrk;
wrk->vsl = bo->vsl;
+#if 0
if (bo->stale_oc != NULL) {
CHECK_OBJ_NOTNULL(bo->stale_oc, OBJCORE_MAGIC);
/* We don't want the oc/stevedore ops in fetching thread */
if (!ObjCheckFlag(wrk, bo->stale_oc, OF_IMSCAND))
(void)HSH_DerefObjCore(wrk, &bo->stale_oc);
}
+#endif
while (stp != F_STP_DONE) {
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
diff --git a/bin/varnishtest/tests/c00072.vtc b/bin/varnishtest/tests/c00072.vtc
new file mode 100644
index 0000000..19453a0
--- /dev/null
+++ b/bin/varnishtest/tests/c00072.vtc
@@ -0,0 +1,50 @@
+varnishtest "purge stale on refresh with and without IMS"
+
+server s1 {
+ rxreq
+ txresp -hdr "foo: bar"
+ rxreq
+ txresp -hdr "foo: bar" -hdr {ETag: "asdf"}
+
+ rxreq
+ txresp -hdr "foo: baz"
+ rxreq
+ expect req.http.if-none-match == {"asdf"}
+ txresp -status 304 -nolen -hdr "foo: baz"
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_backend_response {
+ set beresp.ttl = 0.1s;
+ set beresp.grace = 0s;
+ set beresp.keep = 60s;
+ }
+} -start
+
+client c1 {
+ txreq -url /no-ims
+ rxresp
+ expect resp.http.foo == "bar"
+ txreq -url /ims
+ rxresp
+ expect resp.http.foo == "bar"
+} -run
+
+# Wait for ttl to expire on both objects
+delay 0.2
+varnish v1 -expect n_object == 2
+
+client c1 {
+ txreq -url /no-ims
+ rxresp
+ expect resp.http.foo == "baz"
+ txreq -url /ims
+ rxresp
+ expect resp.http.foo == "baz"
+} -run
+
+# Make sure expiry is done
+delay 1
+
+# Only one of each of /no-ims and /ims should be left
+varnish v1 -expect n_object == 2
More information about the varnish-commit
mailing list