r2984 - in trunk/varnish-cache: bin/varnishd include lib/libvcl
phk at projects.linpro.no
phk at projects.linpro.no
Tue Jul 22 10:06:16 CEST 2008
Author: phk
Date: 2008-07-22 10:06:16 +0200 (Tue, 22 Jul 2008)
New Revision: 2984
Modified:
trunk/varnish-cache/bin/varnishd/cache_panic.c
trunk/varnish-cache/bin/varnishd/cache_vrt.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:
Add a "panic" vcl command, which does what you would expect.
Takes a string argument, so it is possible to do:
panic "Trouble with " req.url " (not the way I expected it!);
Modified: trunk/varnish-cache/bin/varnishd/cache_panic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_panic.c 2008-07-22 07:52:00 UTC (rev 2983)
+++ trunk/varnish-cache/bin/varnishd/cache_panic.c 2008-07-22 08:06:16 UTC (rev 2984)
@@ -246,16 +246,24 @@
const char *q;
const struct sess *sp;
- if (xxx) {
+ switch(xxx) {
+ case 2:
vsb_printf(vsp,
+ "Panic from VCL:\n%s\n", cond);
+ break;
+ case 1:
+ vsb_printf(vsp,
"Missing errorhandling code in %s(), %s line %d:\n"
" Condition(%s) not true.",
func, file, line, cond);
- } else {
+ break;
+ default:
+ case 0:
vsb_printf(vsp,
"Assert error in %s(), %s line %d:\n"
" Condition(%s) not true.",
func, file, line, cond);
+ break;
}
if (err)
vsb_printf(vsp, " errno = %d (%s)", err, strerror(err));
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2008-07-22 07:52:00 UTC (rev 2983)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2008-07-22 08:06:16 UTC (rev 2984)
@@ -627,6 +627,20 @@
/*--------------------------------------------------------------------*/
void
+VRT_panic(struct sess *sp, const char *str, ...)
+{
+ va_list ap;
+ char *b;
+
+ va_start(ap, str);
+ b = vrt_assemble_string(sp->http, "PANIC: ", str, ap);
+ va_end(ap);
+ lbv_assert("VCL", "", 0, b, 0, 2);
+}
+
+/*--------------------------------------------------------------------*/
+
+void
VRT_purge(const char *regexp, int hash)
{
Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h 2008-07-22 07:52:00 UTC (rev 2983)
+++ trunk/varnish-cache/include/vrt.h 2008-07-22 08:06:16 UTC (rev 2984)
@@ -141,6 +141,7 @@
int VRT_re_test(struct vsb *, const char *, int sub);
const char *VRT_regsub(const struct sess *sp, int all, const char *, void *, const char *);
+void VRT_panic(struct sess *sp, const char *, ...);
void VRT_purge(const char *, int hash);
void VRT_count(const struct sess *, unsigned);
Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_action.c 2008-07-22 07:52:00 UTC (rev 2983)
+++ trunk/varnish-cache/lib/libvcl/vcc_action.c 2008-07-22 08:06:16 UTC (rev 2984)
@@ -355,6 +355,24 @@
/*--------------------------------------------------------------------*/
+static void
+parse_panic(struct tokenlist *tl)
+{
+ vcc_NextToken(tl);
+
+ Fb(tl, 1, "VRT_panic(sp, ");
+ if (!vcc_StringVal(tl)) {
+ vcc_ExpectedStringval(tl);
+ return;
+ }
+ do
+ Fb(tl, 0, ", ");
+ while (vcc_StringVal(tl));
+ Fb(tl, 0, " 0);\n");
+}
+
+/*--------------------------------------------------------------------*/
+
typedef void action_f(struct tokenlist *tl);
static struct action_table {
@@ -367,15 +385,17 @@
#include "vcl_returns.h"
#undef VCL_RET_MAC
#undef VCL_RET_MAC_E
- { "call", parse_call },
- { "set", parse_set },
- { "unset", parse_unset },
- { "remove", parse_unset }, /* backward compatibility */
- { "purge_url", parse_purge_url },
- { "purge_hash", parse_purge_hash },
- { "esi", parse_esi },
- { NULL, NULL }
+ /* Keep list sorted from here */
+ { "call", parse_call },
+ { "esi", parse_esi },
+ { "panic", parse_panic },
+ { "purge_hash", parse_purge_hash },
+ { "purge_url", parse_purge_url },
+ { "remove", parse_unset }, /* backward compatibility */
+ { "set", parse_set },
+ { "unset", parse_unset },
+ { NULL, NULL }
};
void
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2008-07-22 07:52:00 UTC (rev 2983)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2008-07-22 08:06:16 UTC (rev 2984)
@@ -422,6 +422,7 @@
vsb_cat(sb, "int VRT_re_test(struct vsb *, const char *, int sub);\n");
vsb_cat(sb, "const char *VRT_regsub(const struct sess *sp, int all, const char *, void *, const char *);\n");
vsb_cat(sb, "\n");
+ vsb_cat(sb, "void VRT_panic(struct sess *sp, const char *, ...);\n");
vsb_cat(sb, "void VRT_purge(const char *, int hash);\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "void VRT_count(const struct sess *, unsigned);\n");
More information about the varnish-commit
mailing list