r1761 - in trunk/varnish-cache: bin/varnishd include lib/libvcl
cecilihf at projects.linpro.no
cecilihf at projects.linpro.no
Wed Jul 25 10:39:10 CEST 2007
Author: cecilihf
Date: 2007-07-25 10:39:10 +0200 (Wed, 25 Jul 2007)
New Revision: 1761
Modified:
trunk/varnish-cache/bin/varnishd/cache_ban.c
trunk/varnish-cache/include/vrt.h
trunk/varnish-cache/lib/libvcl/vcc_action.c
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
Log:
Implemented http purge with regexp. Example vcl usage:
sub vcl_recv {
if (req.request == "REPURGE") {
purge(req.url);
error 404 "Purged";
}
}
Modified: trunk/varnish-cache/bin/varnishd/cache_ban.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_ban.c 2007-07-24 16:44:11 UTC (rev 1760)
+++ trunk/varnish-cache/bin/varnishd/cache_ban.c 2007-07-25 08:39:10 UTC (rev 1761)
@@ -40,6 +40,7 @@
#include "shmlog.h"
#include "cli_priv.h"
#include "cache.h"
+#include "vrt.h"
struct ban {
TAILQ_ENTRY(ban) list;
@@ -114,3 +115,9 @@
AddBan("a");
}
+
+void
+VRT_repurge(const char *regexp)
+{
+ AddBan(regexp);
+}
Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h 2007-07-24 16:44:11 UTC (rev 1760)
+++ trunk/varnish-cache/include/vrt.h 2007-07-25 08:39:10 UTC (rev 1761)
@@ -70,6 +70,8 @@
int VRT_re_test(struct vsb *, const char *, int sub);
const char *VRT_regsub(struct sess *sp, const char *, void *, const char *);
+void VRT_repurge(const char *);
+
void VRT_count(struct sess *, unsigned);
int VRT_rewrite(const char *, const char *);
void VRT_error(struct sess *, unsigned, const char *);
Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_action.c 2007-07-24 16:44:11 UTC (rev 1760)
+++ trunk/varnish-cache/lib/libvcl/vcc_action.c 2007-07-25 08:39:10 UTC (rev 1761)
@@ -263,6 +263,28 @@
/*--------------------------------------------------------------------*/
+static void
+parse_repurge(struct tokenlist *tl)
+{
+ vcc_NextToken(tl);
+
+ Fb(tl, 0, "VRT_repurge(");
+
+ Expect(tl, '(');
+ vcc_NextToken(tl);
+
+ if (!vcc_StringVal(tl)) {
+ vcc_ExpectedStringval(tl);
+ }
+
+ Expect(tl, ')');
+ vcc_NextToken(tl);
+ Fb(tl, 0, ");");
+}
+
+
+/*--------------------------------------------------------------------*/
+
typedef void action_f(struct tokenlist *tl);
static struct action_table {
@@ -277,6 +299,7 @@
{ "call", parse_call },
{ "set", parse_set },
{ "remove", parse_remove },
+ { "purge", parse_repurge },
{ NULL, NULL }
};
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-07-24 16:44:11 UTC (rev 1760)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-07-25 08:39:10 UTC (rev 1761)
@@ -426,6 +426,8 @@
vsb_cat(sb, "int VRT_re_test(struct vsb *, const char *, int sub);\n");
vsb_cat(sb, "const char *VRT_regsub(struct sess *sp, const char *, void *, const char *);\n");
vsb_cat(sb, "\n");
+ vsb_cat(sb, "void VRT_repurge(const char *);\n");
+ vsb_cat(sb, "\n");
vsb_cat(sb, "void VRT_count(struct sess *, unsigned);\n");
vsb_cat(sb, "int VRT_rewrite(const char *, const char *);\n");
vsb_cat(sb, "void VRT_error(struct sess *, unsigned, const char *);\n");
More information about the varnish-commit
mailing list