r4703 - in branches/2.1: . varnish-cache/bin/varnishd varnish-cache/bin/varnishtest/tests varnish-cache/include varnish-cache/lib/libvarnish varnish-cache/lib/libvcl
tfheen at varnish-cache.org
tfheen at varnish-cache.org
Wed Apr 21 11:18:39 CEST 2010
Author: tfheen
Date: 2010-04-21 11:18:39 +0200 (Wed, 21 Apr 2010)
New Revision: 4703
Added:
branches/2.1/varnish-cache/bin/varnishtest/tests/c00033.vtc
Modified:
branches/2.1/
branches/2.1/varnish-cache/bin/varnishd/cache_backend.h
branches/2.1/varnish-cache/bin/varnishd/cache_backend_cfg.c
branches/2.1/varnish-cache/bin/varnishd/cache_hash.c
branches/2.1/varnish-cache/bin/varnishd/cache_vrt.c
branches/2.1/varnish-cache/bin/varnishd/vparam.h
branches/2.1/varnish-cache/bin/varnishtest/tests/c00019.vtc
branches/2.1/varnish-cache/bin/varnishtest/tests/r00325.vtc
branches/2.1/varnish-cache/bin/varnishtest/tests/r00416.vtc
branches/2.1/varnish-cache/bin/varnishtest/tests/v00011.vtc
branches/2.1/varnish-cache/include/vct.h
branches/2.1/varnish-cache/include/vev.h
branches/2.1/varnish-cache/include/vrt.h
branches/2.1/varnish-cache/lib/libvarnish/tcp.c
branches/2.1/varnish-cache/lib/libvarnish/vev.c
branches/2.1/varnish-cache/lib/libvcl/vcc_dir_random.c
branches/2.1/varnish-cache/lib/libvcl/vcc_fixed_token.c
Log:
Merge r4668: Add a, for now, unsupported & experimental facility.
See test-case for details.
Property changes on: branches/2.1
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk:4637,4640,4643-4645,4647-4650,4654-4667
+ /trunk:4637,4640,4643-4645,4647-4650,4654-4668
Property changes on: branches/2.1/varnish-cache/bin/varnishd/cache_backend.h
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/bin/varnishd/cache_backend.h:4637,4643-4645,4647-4650,4654-4667
+ /trunk/varnish-cache/bin/varnishd/cache_backend.h:4637,4643-4645,4647-4650,4654-4668
Property changes on: branches/2.1/varnish-cache/bin/varnishd/cache_backend_cfg.c
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c:4637,4643-4645,4647-4650,4654-4667
+ /trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c:4637,4643-4645,4647-4650,4654-4668
Modified: branches/2.1/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- branches/2.1/varnish-cache/bin/varnishd/cache_hash.c 2010-04-21 09:01:56 UTC (rev 4702)
+++ branches/2.1/varnish-cache/bin/varnishd/cache_hash.c 2010-04-21 09:18:39 UTC (rev 4703)
@@ -308,6 +308,8 @@
return (oc);
}
+/**********************************************************************
+ */
struct objcore *
HSH_Lookup(struct sess *sp, struct objhead **poh)
@@ -353,8 +355,8 @@
VTAILQ_FOREACH(oc, &oh->objcs, list) {
/* Must be at least our own ref + the objcore we examine */
assert(oh->refcnt > 1);
+ CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
assert(oc->objhead == oh);
- CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
if (oc->flags & OC_F_PERSISTENT)
SMP_Fixup(sp, oh, oc);
@@ -455,6 +457,9 @@
return (oc);
}
+/**********************************************************************
+ */
+
static void
hsh_rush(struct objhead *oh)
{
@@ -483,6 +488,56 @@
}
/**********************************************************************
+ * Purge an entire objhead
+ */
+
+void
+HSH_Purge(struct sess *sp, struct objhead *oh, double ttl, double grace)
+{
+ struct objcore *oc, **ocp;
+ unsigned spc, nobj, n;
+ struct object *o;
+
+ CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
+ spc = WS_Reserve(sp->wrk->ws, 0);
+ ocp = (void*)sp->wrk->ws->f;
+ Lck_Lock(&oh->mtx);
+ assert(oh->refcnt > 0);
+ nobj = 0;
+ VTAILQ_FOREACH(oc, &oh->objcs, list) {
+ CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+ assert(oc->objhead == oh);
+
+ if (oc->flags & OC_F_PERSISTENT)
+ SMP_Fixup(sp, oh, oc);
+
+ xxxassert(spc >= sizeof *ocp);
+ oc->refcnt++;
+ spc -= sizeof *ocp;
+ ocp[nobj++] = oc;
+ }
+ Lck_Unlock(&oh->mtx);
+
+ if (ttl <= 0)
+ ttl = -1;
+ for (n = 0; n < nobj; n++) {
+ oc = ocp[n];
+ CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+ o = oc->obj;
+ if (o == NULL)
+ continue;
+ CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
+ o->ttl = sp->t_req + ttl;
+ if (!isnan(grace))
+ o->grace = grace;
+ EXP_Rearm(o);
+ HSH_Deref(sp->wrk, &o);
+ }
+ WS_Release(sp->wrk->ws, 0);
+}
+
+
+/**********************************************************************
* Kill a busy object we don't need anyway.
* There may be sessions on the waiting list, so we cannot just blow
* it out of the water.
Modified: branches/2.1/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- branches/2.1/varnish-cache/bin/varnishd/cache_vrt.c 2010-04-21 09:01:56 UTC (rev 4702)
+++ branches/2.1/varnish-cache/bin/varnishd/cache_vrt.c 2010-04-21 09:18:39 UTC (rev 4703)
@@ -1024,6 +1024,19 @@
}
/*--------------------------------------------------------------------
+ * "real" purges
+ */
+
+void
+VRT_purge(struct sess *sp, double ttl, double grace)
+{
+ if (sp->cur_method == VCL_MET_HIT)
+ HSH_Purge(sp, sp->obj->objcore->objhead, ttl, grace);
+ else if (sp->cur_method == VCL_MET_MISS)
+ HSH_Purge(sp, sp->objcore->objhead, ttl, grace);
+}
+
+/*--------------------------------------------------------------------
* Simple stuff
*/
Property changes on: branches/2.1/varnish-cache/bin/varnishd/vparam.h
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/bin/varnishd/vparam.h:4637,4643-4645,4647-4650,4654-4667
+ /trunk/varnish-cache/bin/varnishd/vparam.h:4637,4643-4645,4647-4650,4654-4668
Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/c00019.vtc
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/bin/varnishtest/tests/c00019.vtc:4637,4643-4645,4647-4650,4654-4667
+ /trunk/varnish-cache/bin/varnishtest/tests/c00019.vtc:4637,4643-4645,4647-4650,4654-4668
Copied: branches/2.1/varnish-cache/bin/varnishtest/tests/c00033.vtc (from rev 4668, trunk/varnish-cache/bin/varnishtest/tests/c00033.vtc)
===================================================================
--- branches/2.1/varnish-cache/bin/varnishtest/tests/c00033.vtc (rev 0)
+++ branches/2.1/varnish-cache/bin/varnishtest/tests/c00033.vtc 2010-04-21 09:18:39 UTC (rev 4703)
@@ -0,0 +1,89 @@
+# $Id$
+
+test "real purges"
+
+server s1 {
+ rxreq
+ txresp -hdr "Vary: foo" -bodylen 1
+ rxreq
+ txresp -hdr "Vary: foo" -bodylen 2
+ rxreq
+ txresp -hdr "Vary: foo" -bodylen 3
+ rxreq
+ txresp -hdr "Vary: foo" -bodylen 4
+ rxreq
+ txresp -hdr "Vary: foo" -bodylen 5
+ rxreq
+ txresp -hdr "Vary: foo" -bodylen 6
+} -start
+
+varnish v1 -vcl+backend {
+
+ sub vcl_recv {
+ if (req.request == "PURGE") {
+ return (lookup);
+ }
+ }
+
+ sub vcl_hit {
+ if (req.request == "PURGE") {
+ C{ VRT_purge(sp, 0, 0); }C
+ error 456 "got it";
+ }
+ }
+ sub vcl_miss {
+ if (req.request == "PURGE") {
+ C{ VRT_purge(sp, 0, 0); }C
+ error 456 "got it";
+ }
+ }
+} -start
+
+client c1 {
+ txreq -hdr "foo: bar1"
+ rxresp
+ expect resp.bodylen == 1
+
+ txreq -hdr "foo: bar2"
+ rxresp
+ expect resp.bodylen == 2
+
+ txreq -hdr "foo: bar1"
+ rxresp
+ expect resp.bodylen == 1
+
+ txreq -hdr "foo: bar2"
+ rxresp
+ expect resp.bodylen == 2
+
+ txreq -req "PURGE" -hdr "foo: bar1"
+ rxresp
+ expect resp.status == 456
+} -run
+
+client c1 {
+ txreq -hdr "foo: bar1"
+ rxresp
+ expect resp.bodylen == 3
+
+ txreq -hdr "foo: bar2"
+ rxresp
+ expect resp.bodylen == 4
+
+ txreq -req "PURGE" -hdr "foo: bar3"
+ rxresp
+ expect resp.status == 456
+} -run
+
+client c1 {
+ txreq -hdr "foo: bar1"
+ rxresp
+ expect resp.bodylen == 5
+
+ txreq -hdr "foo: bar2"
+ rxresp
+ expect resp.bodylen == 6
+
+} -run
+
+
Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/r00325.vtc
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/bin/varnishtest/tests/r00325.vtc:4637,4643-4645,4647-4650,4654-4667
+ /trunk/varnish-cache/bin/varnishtest/tests/r00325.vtc:4637,4643-4645,4647-4650,4654-4668
Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/r00416.vtc
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/bin/varnishtest/tests/r00416.vtc:4637,4643-4645,4647-4650,4654-4667
+ /trunk/varnish-cache/bin/varnishtest/tests/r00416.vtc:4637,4643-4645,4647-4650,4654-4668
Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/v00011.vtc
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/bin/varnishtest/tests/v00011.vtc:4637,4643-4645,4647-4650,4654-4667
+ /trunk/varnish-cache/bin/varnishtest/tests/v00011.vtc:4637,4643-4645,4647-4650,4654-4668
Property changes on: branches/2.1/varnish-cache/include/vct.h
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/include/vct.h:4637,4643-4645,4647-4650,4654-4667
+ /trunk/varnish-cache/include/vct.h:4637,4643-4645,4647-4650,4654-4668
Property changes on: branches/2.1/varnish-cache/include/vev.h
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/include/vev.h:4637,4643-4645,4647-4650,4654-4667
+ /trunk/varnish-cache/include/vev.h:4637,4643-4645,4647-4650,4654-4668
Modified: branches/2.1/varnish-cache/include/vrt.h
===================================================================
--- branches/2.1/varnish-cache/include/vrt.h 2010-04-21 09:01:56 UTC (rev 4702)
+++ branches/2.1/varnish-cache/include/vrt.h 2010-04-21 09:18:39 UTC (rev 4703)
@@ -138,6 +138,7 @@
void VRT_panic(struct sess *sp, const char *, ...);
void VRT_ban(struct sess *sp, char *, ...);
void VRT_ban_string(struct sess *sp, const char *, ...);
+void VRT_purge(struct sess *sp, double ttl, double grace);
void VRT_count(const struct sess *, unsigned);
int VRT_rewrite(const char *, const char *);
Property changes on: branches/2.1/varnish-cache/lib/libvarnish/tcp.c
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/lib/libvarnish/tcp.c:4637,4643-4645,4647-4650,4654-4667
+ /trunk/varnish-cache/lib/libvarnish/tcp.c:4637,4643-4645,4647-4650,4654-4668
Property changes on: branches/2.1/varnish-cache/lib/libvarnish/vev.c
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/lib/libvarnish/vev.c:4637,4643-4645,4647-4650,4654-4667
+ /trunk/varnish-cache/lib/libvarnish/vev.c:4637,4643-4645,4647-4650,4654-4668
Property changes on: branches/2.1/varnish-cache/lib/libvcl/vcc_dir_random.c
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/lib/libvcl/vcc_dir_random.c:4637,4643-4645,4647-4650,4654-4667
+ /trunk/varnish-cache/lib/libvcl/vcc_dir_random.c:4637,4643-4645,4647-4650,4654-4668
Modified: branches/2.1/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- branches/2.1/varnish-cache/lib/libvcl/vcc_fixed_token.c 2010-04-21 09:01:56 UTC (rev 4702)
+++ branches/2.1/varnish-cache/lib/libvcl/vcc_fixed_token.c 2010-04-21 09:18:39 UTC (rev 4703)
@@ -227,8 +227,8 @@
vsb_cat(sb, " * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWI");
vsb_cat(sb, "SE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFT");
vsb_cat(sb, "WARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n");
- vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 4428 2010-01-06 17:");
- vsb_cat(sb, "38:59Z tfheen $\n *\n * Runtime support for compiled V");
+ vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 4695 2010-04-19 13:");
+ vsb_cat(sb, "03:14Z tfheen $\n *\n * Runtime support for compiled V");
vsb_cat(sb, "CL programs.\n *\n * XXX: When this file is changed, l");
vsb_cat(sb, "ib/libvcl/vcc_gen_fixed_token.tcl\n");
vsb_cat(sb, " * XXX: *MUST* be rerun.\n */\n");
@@ -281,8 +281,9 @@
vsb_cat(sb, "\nvoid VRT_panic(struct sess *sp, const char *, ...);\n");
vsb_cat(sb, "void VRT_ban(struct sess *sp, char *, ...);\n");
vsb_cat(sb, "void VRT_ban_string(struct sess *sp, const char *, ...");
- vsb_cat(sb, ");\n\nvoid VRT_count(const struct sess *, unsigned);\n");
- vsb_cat(sb, "int VRT_rewrite(const char *, const char *);\n");
+ vsb_cat(sb, ");\nvoid VRT_purge(struct sess *sp, double ttl, double");
+ vsb_cat(sb, " grace);\n\nvoid VRT_count(const struct sess *, unsign");
+ vsb_cat(sb, "ed);\nint VRT_rewrite(const char *, const char *);\n");
vsb_cat(sb, "void VRT_error(struct sess *, unsigned, const char *);");
vsb_cat(sb, "\nint VRT_switch_config(const char *);\n");
vsb_cat(sb, "\nenum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BERE");
More information about the varnish-commit
mailing list