r3709 - in branches/2.0/varnish-cache/bin: varnishd varnishtest/tests
tfheen at projects.linpro.no
tfheen at projects.linpro.no
Mon Feb 9 14:10:35 CET 2009
Author: tfheen
Date: 2009-02-09 14:10:34 +0100 (Mon, 09 Feb 2009)
New Revision: 3709
Modified:
branches/2.0/varnish-cache/bin/varnishd/cache_ban.c
branches/2.0/varnish-cache/bin/varnishtest/tests/c00019.vtc
branches/2.0/varnish-cache/bin/varnishtest/tests/c00021.vtc
Log:
Merge r3520+r3521: Set cost 10 on regexp tests.
Let purge.list prune the tail of the list before dumping.
Add a protective object to prevent purge.list from pruning our
purges before we test their numbers.
Modified: branches/2.0/varnish-cache/bin/varnishd/cache_ban.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_ban.c 2009-02-09 12:58:27 UTC (rev 3708)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_ban.c 2009-02-09 13:10:34 UTC (rev 3709)
@@ -154,6 +154,8 @@
regfree(&bt->re);
if (bt->dst != NULL)
free(bt->dst);
+ if (bt->src != NULL)
+ free(bt->src);
FREE_OBJ(bt);
}
FREE_OBJ(b);
@@ -276,6 +278,7 @@
return (-1);
}
bt->flags |= BAN_T_REGEXP;
+ bt->cost = 10;
return (0);
}
@@ -429,6 +432,23 @@
Lck_Unlock(&ban_mtx);
}
+static struct ban *
+BAN_CheckLast(void)
+{
+ struct ban *b;
+
+ Lck_AssertHeld(&ban_mtx);
+ b = VTAILQ_LAST(&ban_head, banhead);
+ if (b != VTAILQ_FIRST(&ban_head) && b->refcount == 0) {
+ VSL_stats->n_purge--;
+ VSL_stats->n_purge_retire++;
+ VTAILQ_REMOVE(&ban_head, b, list);
+ } else {
+ b = NULL;
+ }
+ return (b);
+}
+
void
BAN_DestroyObj(struct object *o)
{
@@ -442,21 +462,15 @@
o->ban->refcount--;
o->ban = NULL;
- /* Check if we can purge the last ban entry */
- b = VTAILQ_LAST(&ban_head, banhead);
- if (b != VTAILQ_FIRST(&ban_head) && b->refcount == 0) {
- VSL_stats->n_purge--;
- VSL_stats->n_purge_retire++;
- VTAILQ_REMOVE(&ban_head, b, list);
- } else {
- b = NULL;
- }
+ /* Attempt to purge last ban entry */
+ b = BAN_CheckLast();
Lck_Unlock(&ban_mtx);
if (b != NULL)
ban_free_ban(b);
}
+
int
BAN_CheckObject(struct object *o, const struct sess *sp)
{
@@ -608,9 +622,16 @@
(void)av;
(void)priv;
- Lck_Lock(&ban_mtx);
- VTAILQ_LAST(&ban_head, banhead)->refcount++;
- Lck_Unlock(&ban_mtx);
+ do {
+ /* Attempt to purge last ban entry */
+ Lck_Lock(&ban_mtx);
+ b = BAN_CheckLast();
+ if (b == NULL)
+ VTAILQ_LAST(&ban_head, banhead)->refcount++;
+ Lck_Unlock(&ban_mtx);
+ if (b != NULL)
+ ban_free_ban(b);
+ } while (b != NULL);
VTAILQ_FOREACH(b, &ban_head, list) {
if (b->flags & BAN_F_GONE)
Modified: branches/2.0/varnish-cache/bin/varnishtest/tests/c00019.vtc
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/c00019.vtc 2009-02-09 12:58:27 UTC (rev 3708)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/c00019.vtc 2009-02-09 13:10:34 UTC (rev 3709)
@@ -4,6 +4,8 @@
server s1 {
rxreq
+ txresp -hdr "foo: 0" -body "foo0"
+ rxreq
txresp -hdr "foo: 1" -body "foo1"
rxreq
txresp -hdr "foo: 2" -body "foo2"
@@ -22,6 +24,9 @@
# Our fetch is not affected by the purge
# as the FOO-purge was preexisting
client c1 {
+ txreq -url /BAR
+ rxresp
+ expect resp.http.foo == 0
txreq -url /FOO
rxresp
expect resp.http.foo == 1
@@ -64,7 +69,7 @@
# Enable dup removal of purges
varnish v1 -cliok "param.set purge_dups on"
-# This should incapacitate the to previous FOO purges.
+# This should incapacitate the two previous FOO purges.
varnish v1 -cliok "purge.url FOO"
varnish v1 -expect n_purge_add == 6
varnish v1 -expect n_purge_dups == 3
Modified: branches/2.0/varnish-cache/bin/varnishtest/tests/c00021.vtc
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/c00021.vtc 2009-02-09 12:58:27 UTC (rev 3708)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/c00021.vtc 2009-02-09 13:10:34 UTC (rev 3709)
@@ -112,7 +112,7 @@
} -run
# header check, no header
-varnish v1 -cliok "purge obj.http.bar == barcheck"
+varnish v1 -cliok "purge req.url ~ foo && obj.http.bar == barcheck"
varnish v1 -cliok "purge.list"
client c1 {
More information about the varnish-commit
mailing list