From: phk Date: Wed, 17 Oct 2007 08:32:19 +0000 (+0000) Subject: Add error messages from the XML/ESI parser X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd549509c2871e41ef540f4a15a9972f48105963;p=varnish Add error messages from the XML/ESI parser git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2110 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_vrt_esi.c b/varnish-cache/bin/varnishd/cache_vrt_esi.c index f71b6cfe..0e1cff1b 100644 --- a/varnish-cache/bin/varnishd/cache_vrt_esi.c +++ b/varnish-cache/bin/varnishd/cache_vrt_esi.c @@ -61,6 +61,54 @@ add_piece(txt t, int kind) printf("K%d \"%.*s\"\n", kind, t.e - t.b, t.b); } +static void +vxml_error(struct sess *sp, const char *p, txt t, size_t off, int i, const char *err) +{ + int ellipsis = 0; + char buf[256], *q; + + if (i == 0) { + i = t.e - p; + } + if (i > 20) { + i = 20; + ellipsis = 1; + } + q = buf; + q += sprintf(buf, "at %d: %s \"", off + (p - t.b), err); + while (i > 0) { + if (*p >= ' ' && *p <= '~') { + *q++ = *p; + } else if (*p == '\n') { + *q++ = '\\'; + *q++ = 'n'; + } else if (*p == '\r') { + *q++ = '\\'; + *q++ = 'r'; + } else if (*p == '\t') { + *q++ = '\\'; + *q++ = 't'; + } else { + /* XXX: use %%%02x instead ? */ + q += sprintf(q, "\\x%02x", *p); + } + p++; + i--; + } + if (ellipsis) { + *q++ = '['; + *q++ = '.'; + *q++ = '.'; + *q++ = '.'; + *q++ = ']'; + } + *q++ = '"'; + *q++ = '\0'; + t.b = buf; + t.e = q; + WSPR(sp, SLT_ESI_xmlerror, t); +} + /*-------------------------------------------------------------------- * Zoom over a piece of object and dike out all releveant esi: pieces. * The entire txt may not be processed because an interesting part @@ -69,7 +117,7 @@ add_piece(txt t, int kind) */ static int -vxml(txt t) +vxml(struct sess *sp, txt t, size_t off) { char *p, *q, *r; txt o; @@ -165,7 +213,11 @@ vxml(txt t) } if (p[1] == '!') { - /* Ignore unrecognized obj, OBJECT_MAGIC); + o = 1; VTAILQ_FOREACH(st, &sp->obj->store, list) { t.b = (void*)st->ptr; t.e = t.b + st->len; - i = vxml(t); + i = vxml(sp, t, o); + o += st->len; printf("VXML(%p+%d) = %d", st->ptr, st->len, i); if (i < st->len) printf(" \"%.*s\"", st->len - i, st->ptr + i); diff --git a/varnish-cache/include/shmlog_tags.h b/varnish-cache/include/shmlog_tags.h index 753ddac8..4238d161 100644 --- a/varnish-cache/include/shmlog_tags.h +++ b/varnish-cache/include/shmlog_tags.h @@ -92,3 +92,6 @@ SLTM(ExpPick) SLTM(ExpKill) SLTM(WorkThread) SLTM(Terminate) + +SLTM(ESItrace) +SLTM(ESI_xmlerror)