]> err.no Git - varnish/commitdiff
NB: Be careful with -trunk, this is a quite intrusive change.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 25 Jul 2008 18:20:35 +0000 (18:20 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 25 Jul 2008 18:20:35 +0000 (18:20 +0000)
Continue the progress on synthetic/error pages

The default "guru meditation" is now generated from the vcl_error {}
function, which can be redefined to whatever suits your taste.

Techinical:

Add new vcl_error method and make variables available in it.

Fix a bug in "error" action, where the numeric argument would not get
interpreted correctly if it came from a variable like obj.status.

Forbid "error" action in vcl_deliver since vcl_error now goes to
vcl_deliver to send the error object.

Fix test v00001 to reflect this.

Move the obj->ws/http initialization to preallocation time to avoid
duplication.

Add read-only variable req.xid (a string!)

Add default guru meditation to default vcl.

Remove cache_synthetic.c which is now unecessary.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3027 d4fa192b-c00b-0410-8231-f00ffab90ce4

16 files changed:
varnish-cache/bin/varnishd/Makefile.am
varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/cache_fetch.c
varnish-cache/bin/varnishd/cache_hash.c
varnish-cache/bin/varnishd/cache_synthetic.c [deleted file]
varnish-cache/bin/varnishd/cache_vrt.c
varnish-cache/bin/varnishd/mgt_vcc.c
varnish-cache/bin/varnishtest/tests/v00001.vtc
varnish-cache/include/vcl.h
varnish-cache/include/vcl_returns.h
varnish-cache/include/vrt_obj.h
varnish-cache/lib/libvcl/vcc_action.c
varnish-cache/lib/libvcl/vcc_fixed_token.c
varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
varnish-cache/lib/libvcl/vcc_gen_obj.tcl
varnish-cache/lib/libvcl/vcc_obj.c

index ebf01107288f3641965f46235d462cf024b9d029..e8157315062b4c3b0f43c531e334e1c6e651f250 100644 (file)
@@ -31,7 +31,6 @@ varnishd_SOURCES = \
        cache_pipe.c \
        cache_response.c \
        cache_session.c \
-       cache_synthetic.c \
        cache_vary.c \
        cache_vcl.c \
        cache_vrt.c \
index 11ad722e79f912ec440a42a182234ec8e5de3bf3..1b0ce8cd8ec41df936e9e2f9390a2e47fc3022a8 100644 (file)
@@ -306,12 +306,40 @@ DOT error -> DONE
 static int
 cnt_error(struct sess *sp)
 {
+       struct worker *w;
+       struct http *h;
+       time_t now;
+       char date[40];
 
-       AZ(sp->obj);
-       SYN_ErrorPage(sp, sp->err_code, sp->err_reason);
+       CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+       w = sp->wrk;
+       if (sp->obj == NULL) {
+               HSH_Prealloc(sp);
+               sp->obj = sp->wrk->nobj;
+               sp->wrk->nobj = NULL;
+       } else {
+               /* XXX: Null the headers ? */
+       }
+       CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
+       h = sp->obj->http;
+
+       http_PutProtocol(w, sp->fd, h, "HTTP/1.1");
+       http_PutStatus(w, sp->fd, h, sp->err_code);
+       now = TIM_real();
+       TIM_format(now, date);
+        http_PrintfHeader(w, sp->fd, h, "Date: %s", date);
+        http_PrintfHeader(w, sp->fd, h, "Server: Varnish");
+        http_PrintfHeader(w, sp->fd, h, "Retry-After: %d", params->err_ttl);
+
+       if (sp->err_reason != NULL)
+               http_PutResponse(w, sp->fd, h, sp->err_reason);
+       else
+               http_PutResponse(w, sp->fd, h,
+                   http_StatusMessage(sp->err_code));
+       VCL_error_method(sp);
        sp->err_code = 0;
        sp->err_reason = NULL;
-       sp->step = STP_DONE;
+       sp->step = STP_DELIVER;
        return (0);
 }
 
@@ -877,8 +905,8 @@ cnt_start(struct sess *sp)
        *sp->http0 = *sp->http;
 
        if (done != 0) {
-               SYN_ErrorPage(sp, done, NULL);          /* XXX: STP_ERROR ? */
-               sp->step = STP_DONE;
+               sp->err_code = done;
+               sp->step = STP_ERROR;
                return (0);
        }
 
index e098dcf731725c940bab4d8db7110941fb0dd740..1202dde67bd178649c2481898f7c1672f6f20aa8 100644 (file)
@@ -331,11 +331,7 @@ Fetch(struct sess *sp)
        sp->obj->xid = sp->xid;
 
        /* Set up obj's workspace */
-       st = sp->obj->objstore;
-       WS_Init(sp->obj->ws_o, "obj", st->ptr + st->len, st->space - st->len);
-       st->len = st->space;
        WS_Assert(sp->obj->ws_o);
-       http_Setup(sp->obj->http, sp->obj->ws_o);
        vc = VBE_GetFd(sp);
        if (vc == NULL)
                return (__LINE__);
index 6eba5876eaf18ead58462f33a3114e0ebe801e35..f84cb4cd1e4851a2dc91c4c09e13c601b41c20d3 100644 (file)
@@ -104,6 +104,11 @@ HSH_Prealloc(struct sess *sp)
                st->len = sizeof *w->nobj;
                memset(w->nobj, 0, sizeof *w->nobj);
                w->nobj->objstore = st;
+               WS_Init(w->nobj->ws_o, "obj",
+                   st->ptr + st->len, st->space - st->len);
+               st->len = st->space;
+               WS_Assert(w->nobj->ws_o);
+               http_Setup(w->nobj->http, w->nobj->ws_o);
                w->nobj->magic = OBJECT_MAGIC;
                w->nobj->http->magic = HTTP_MAGIC;
                w->nobj->busy = 1;
@@ -112,6 +117,7 @@ HSH_Prealloc(struct sess *sp)
                VTAILQ_INIT(&w->nobj->store);
                VTAILQ_INIT(&w->nobj->esibits);
                VSL_stats->n_object++;
+               
        } else
                CHECK_OBJ_NOTNULL(w->nobj, OBJECT_MAGIC);
 }
diff --git a/varnish-cache/bin/varnishd/cache_synthetic.c b/varnish-cache/bin/varnishd/cache_synthetic.c
deleted file mode 100644 (file)
index 91c13fe..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*-
- * Copyright (c) 2007-2008 Linpro AS
- * All rights reserved.
- *
- * Author: Dag-Erling Smørgrav <des@des.no>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id$
- */
-
-#include "config.h"
-
-#include <sys/types.h>
-#include <sys/time.h>
-
-#include <stdlib.h>
-
-#include "shmlog.h"
-#include "cache.h"
-#include "stevedore.h"
-
-/*
- * Synthesize an error page including headers.
- * XXX: For now close the connection.  Long term that should probably
- * XXX: be either a paramter or VCL decision.
- * XXX: VCL should get a shot at generating the page.
- */
-
-void
-SYN_ErrorPage(struct sess *sp, int status, const char *reason)
-{
-       struct http *h;
-       struct worker *w;
-       const char *msg;
-       char date[40];
-       double now;
-       unsigned u;
-       struct vsb vsb;
-       int fd;
-
-       WSL_Flush(sp->wrk, 0);
-       assert(status >= 100 && status <= 999);
-       CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-       CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
-
-       /* shortcuts */
-       w = sp->wrk;
-       h = sp->http;
-       fd = sp->fd;
-       now = TIM_real();               /* XXX: use cached val ? */
-
-       WRK_Reset(w, &sp->fd);
-
-       /* look up HTTP response */
-       msg = http_StatusMessage(status);
-       AN(msg);
-       if (reason == NULL)
-               reason = msg;
-
-       /* generate header */
-       http_ClrHeader(h);
-       h->logtag = HTTP_Tx;
-       http_PutProtocol(w, fd, h, "HTTP/1.0"); /* XXX */
-       http_PutStatus(w, fd, h, status);
-       http_PutResponse(w, fd, h, msg);
-       TIM_format(now, date);
-       http_PrintfHeader(w, fd, h, "Date: %s", date);
-       http_PrintfHeader(w, fd, h, "Server: Varnish");
-       http_PrintfHeader(w, fd, h, "Retry-After: %d", params->err_ttl);
-       http_PrintfHeader(w, fd, h, "Content-Type: text/html; charset=utf-8");
-       http_PrintfHeader(w, sp->fd, sp->http, "X-Varnish: %u", sp->xid);
-       http_PrintfHeader(w, fd, h, "Connection: close");
-
-       w->acct.hdrbytes += http_Write(w, h, 1);
-
-       /* generate body */
-       /* XXX: VCL should do this */
-       u = WS_Reserve(h->ws, 0);
-       AN(vsb_new(&vsb, h->ws->f, u, VSB_FIXEDLEN));
-       vsb_printf(&vsb,
-           "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
-           "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
-           " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
-           "<html>\n"
-           "  <head>\n"
-           "    <title>%03d %s</title>\n", status, msg);
-       vsb_printf(&vsb,
-           "  </head>\n"
-           "  <body>\n"
-           "    <h1>Error %03d %s</h1>\n", status, msg);
-       vsb_printf(&vsb,
-           "    <p>%s</p>\n", reason);
-       vsb_printf(&vsb,
-           "    <h3>Guru Meditation:</h3>\n"
-           "    <p>XID: %u</p>\n", sp->xid);
-       vsb_printf(&vsb,
-           "    <address><a href=\"http://www.varnish-cache.org/\">Varnish</a></address>\n"
-           "  </body>\n"
-           "</html>\n");
-       vsb_finish(&vsb);
-       AZ(vsb_overflowed(&vsb));
-       w->acct.hdrbytes = WRK_Write(w, vsb_data(&vsb), vsb_len(&vsb));
-       (void)WRK_Flush(w);
-       vsb_delete(&vsb);
-       vca_close_session(sp, "error returned");
-}
index cf5919a5b2db9a521a15269a437d4213e0d69992..ecbfb62f6d6ad3ec31998e78dd5c40f6f84ac738 100644 (file)
@@ -467,6 +467,24 @@ VRT_r_req_grace(struct sess *sp)
        return (sp->grace);
 }
 
+/*--------------------------------------------------------------------
+ * req.xid
+ */
+
+/*lint -e{818} sp could be const */
+const char *
+VRT_r_req_xid(struct sess *sp)
+{
+       char *p;
+       int size;
+       CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+
+       size = snprintf(NULL, 0, "%u", sp->xid) + 1;
+       AN(p = WS_Alloc(sp->http->ws, size));
+       assert(snprintf(p, size, "%d", sp->xid) < size);
+       return (p);
+}
+
 /*--------------------------------------------------------------------*/
 
 struct sockaddr *
index 11533d08ed62e7a29d2f242bee87313c94a50807..372ff45580fc0dfac905ed5a0a29b2590ea1cf8c 100644 (file)
@@ -158,7 +158,29 @@ static const char *default_vcl =
     "}\n"
     "sub vcl_timeout {\n"
     "    discard;\n"
-    "}\n";
+    "}\n"
+    "sub vcl_error {\n"
+    "    set obj.http.Content-Type = \"text/html; charset=utf-8\";"
+    "    synthetic {\"\n"
+    "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
+    " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
+    "<html>\n"
+    "  <head>\n"
+    "    <title>\"} obj.status \" \" obj.response {\"</title>\n"
+    "  </head>\n"
+    "  <body>\n"
+    "    <h1>Error \"} obj.status \" \" obj.response {\"</h1>\n"
+    "    <p>\"} obj.response {\"</p>\n"
+    "    <h3>Guru Meditation:</h3>\n"
+    "    <p>XID: \"} req.xid {\"</p>\n"
+    "    <address><a href=\"http://www.varnish-cache.org/\">Varnish</a></address>\n"
+    "  </body>\n"
+    "</html>\n"
+    "\"};\n"
+    "    deliver;\n"
+    "}\n"      
+    "" ;
 
 /*
  * Prepare the compiler command line
index 3292950d0ea25ebd9c73fa1a7f3d31cdaaa37e8f..c912bc8aa2bf4be6a1f62b17b5d4e27d0333ffb0 100644 (file)
@@ -38,11 +38,10 @@ varnish v1 -vcl+backend {
        sub vcl_deliver {
                set resp.proto = "HTTP/1.2";
                set resp.response = "Naah, lets fail it";
-               set resp.status = 903;
+               set resp.status = 904;
                set resp.http.foobar =
                    resp.proto
                    resp.status;
-               error 904 "because I say so:";
        }
 } -start
 
index 18d0479a6e86505423c63467ed391d897b0dde08..54745f1a89ebb5060adca60c643bedf444cf3422 100644 (file)
@@ -46,4 +46,5 @@ struct VCL_conf {
        vcl_func_f      *prefetch_func;
        vcl_func_f      *timeout_func;
        vcl_func_f      *discard_func;
+       vcl_func_f      *error_func;
 };
index d69c8d65aa7a2d9deec662ff6b1dfb9f2022a92a..8359ecab6f52071007e343b2ef561a3816ca662a 100644 (file)
@@ -43,10 +43,11 @@ VCL_MET_MAC(hash,HASH,(VCL_RET_HASH))
 VCL_MET_MAC(miss,MISS,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_FETCH))
 VCL_MET_MAC(hit,HIT,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER))
 VCL_MET_MAC(fetch,FETCH,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_INSERT))
-VCL_MET_MAC(deliver,DELIVER,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_DELIVER))
+VCL_MET_MAC(deliver,DELIVER,(VCL_RET_RESTART|VCL_RET_DELIVER))
 VCL_MET_MAC(prefetch,PREFETCH,(VCL_RET_FETCH|VCL_RET_PASS))
 VCL_MET_MAC(timeout,TIMEOUT,(VCL_RET_FETCH|VCL_RET_DISCARD))
 VCL_MET_MAC(discard,DISCARD,(VCL_RET_DISCARD|VCL_RET_KEEP))
+VCL_MET_MAC(error,ERROR,(VCL_RET_DELIVER))
 #else
 #define VCL_MET_RECV   (1 << 0)
 #define VCL_MET_PIPE   (1 << 1)
@@ -59,5 +60,6 @@ VCL_MET_MAC(discard,DISCARD,(VCL_RET_DISCARD|VCL_RET_KEEP))
 #define VCL_MET_PREFETCH       (1 << 8)
 #define VCL_MET_TIMEOUT        (1 << 9)
 #define VCL_MET_DISCARD        (1 << 10)
+#define VCL_MET_ERROR  (1 << 11)
 #endif
-#define N_METHODS 11
+#define N_METHODS 12
index 39675c25794ba9f89ad4fb5a8951d6da8c8a76c8..aaab2386b69a994bc07a303b3a5d91fdf0775151 100644 (file)
@@ -21,6 +21,7 @@ void VRT_l_req_backend(struct sess *, struct director *);
 int VRT_r_req_restarts(const struct sess *);
 double VRT_r_req_grace(struct sess *);
 void VRT_l_req_grace(struct sess *, double);
+const char * VRT_r_req_xid(struct sess *);
 const char * VRT_r_bereq_request(const struct sess *);
 void VRT_l_bereq_request(const struct sess *, const char *, ...);
 const char * VRT_r_bereq_url(const struct sess *);
index 05dcdddb212b454ead6d8110161f34161daecbc0..a32ee42f437a186f5a8bfce102784922b4c62d7c 100644 (file)
@@ -94,15 +94,22 @@ parse_call(struct tokenlist *tl)
 static void
 parse_error(struct tokenlist *tl)
 {
-       unsigned a;
+       struct var *vp;
 
        vcc_NextToken(tl);
-       if (tl->t->tok == CNUM) {
-               a = vcc_UintVal(tl);
+       if (tl->t->tok == VAR) {
+               vp = vcc_FindVar(tl, tl->t, vcc_vars);
+               if (vp->fmt == INT) {
+                       Fb(tl, 1, "VRT_error(sp, %s", vp->rname);
+                       vcc_NextToken(tl);
+               } else {
+                       Fb(tl, 1, "VRT_error(sp, 0");
+               }
+       } else if (tl->t->tok == CNUM) {
+               Fb(tl, 1, "VRT_error(sp, %u", vcc_UintVal(tl));
                vcc_NextToken(tl);
        } else
-               a = 0;
-       Fb(tl, 1, "VRT_error(sp, %u", a);
+               Fb(tl, 1, "VRT_error(sp, 0");
        if (tl->t->tok == CSTR) {
                Fb(tl, 0, ", %.*s", PF(tl->t));
                vcc_NextToken(tl);
index 89a5cb04de2a23207f660476ecae4ee0876dd909..6c654659cf22bf5f62959adf7960acd58991c843 100644 (file)
@@ -278,6 +278,7 @@ vcl_output_lang_h(struct vsb *sb)
        vsb_cat(sb, "   vcl_func_f      *prefetch_func;\n");
        vsb_cat(sb, "   vcl_func_f      *timeout_func;\n");
        vsb_cat(sb, "   vcl_func_f      *discard_func;\n");
+       vsb_cat(sb, "   vcl_func_f      *error_func;\n");
        vsb_cat(sb, "};\n");
        vsb_cat(sb, "/*-\n");
        vsb_cat(sb, " * Copyright (c) 2006 Verdens Gang AS\n");
@@ -475,6 +476,7 @@ vcl_output_lang_h(struct vsb *sb)
        vsb_cat(sb, "int VRT_r_req_restarts(const struct sess *);\n");
        vsb_cat(sb, "double VRT_r_req_grace(struct sess *);\n");
        vsb_cat(sb, "void VRT_l_req_grace(struct sess *, double);\n");
+       vsb_cat(sb, "const char * VRT_r_req_xid(struct sess *);\n");
        vsb_cat(sb, "const char * VRT_r_bereq_request(const struct sess *);\n");
        vsb_cat(sb, "void VRT_l_bereq_request(const struct sess *, const char *, ...);\n");
        vsb_cat(sb, "const char * VRT_r_bereq_url(const struct sess *);\n");
index 1c23bb7a304dabfb2dd04c74554c19d55cd279c5..bb0771349d3547df9eaddf43ac05020c1cf1e56f 100755 (executable)
@@ -41,10 +41,11 @@ set methods {
        {miss           {error restart pass fetch}}
        {hit            {error restart pass deliver}}
        {fetch          {error restart pass insert}}
-       {deliver        {error restart deliver}}
+       {deliver        {restart deliver}}
        {prefetch       {fetch pass}}
        {timeout        {fetch discard}}
        {discard        {discard keep}}
+       {error          {deliver}}
 }
 
 # These are the return actions
index ed06f538744b0d8a1cc7943f7ba0a8dbb3a1d910..a9b50025c1d710a0ade742098d6e694cf99200be 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/tclsh8.4
+#!/usr/local/bin/tclsh8.4
 #-
 # Copyright (c) 2006 Verdens Gang AS
 # Copyright (c) 2006-2008 Linpro AS
 # Comments are stripped from #...\n
 set spobj {
 
-       # Connection related parameters
-       { client.ip
-               RO IP
-               {recv pipe pass hash miss hit fetch deliver                }
-               "const struct sess *"
-       }
-       { client.bandwidth                               # Not implemented yet
-               NO
-               { }
-               "const struct sess *"
-       }
-       { server.ip
-               RO IP
-               {recv pipe pass hash miss hit fetch deliver                }
-               "struct sess *"
-       }
-       { server.port
-               RO INT
-               {recv pipe pass hash miss hit fetch deliver                }
-               "struct sess *"
-       }
-       # Request paramters
-       { req.request
-               RW STRING
-               {recv pipe pass hash miss hit fetch                        }
-               "const struct sess *"
-       }
-       { req.url
-               RW STRING
-               {recv pipe pass hash miss hit fetch                        }
-               "const struct sess *"
-       }
-       { req.proto
-               RW STRING
-               {recv pipe pass hash miss hit fetch                        }
-               "const struct sess *"
-       }
-       { req.http.
-               RW HDR_REQ
-               {recv pipe pass hash miss hit fetch                        }
-               "const struct sess *"
-       }
+    # Connection related parameters
+    { client.ip
+       RO IP
+       {recv pipe pass hash miss hit fetch deliver                error }
+       "const struct sess *"
+    }
+    { client.bandwidth                          # Not implemented yet
+       NO
+       { }
+       "const struct sess *"
+    }
+    { server.ip
+       RO IP
+       {recv pipe pass hash miss hit fetch deliver                error }
+       "struct sess *"
+    }
+    { server.port
+       RO INT
+       {recv pipe pass hash miss hit fetch deliver                error }
+       "struct sess *"
+    }
+    # Request paramters
+    { req.request
+       RW STRING
+       {recv pipe pass hash miss hit fetch                        error }
+       "const struct sess *"
+    }
+    { req.url
+       RW STRING
+       {recv pipe pass hash miss hit fetch                        error }
+       "const struct sess *"
+    }
+    { req.proto
+       RW STRING
+       {recv pipe pass hash miss hit fetch                        error }
+       "const struct sess *"
+    }
+    { req.http.
+       RW HDR_REQ
+       {recv pipe pass hash miss hit fetch                        error }
+       "const struct sess *"
+    }
 
-       # Possibly misnamed, not really part of the request
-       { req.hash
-               WO HASH
-               {               hash                                       }
-               "struct sess *"
-       }
-       { req.backend
-               RW BACKEND
-               {recv pipe pass hash miss hit fetch                        }
-               "struct sess *"
-       }
-       { req.restarts
-               RO INT
-               {recv pipe pass hash miss hit fetch deliver                }
-               "const struct sess *"
-       }
-       { req.grace
-               RW TIME
-               {recv pipe pass hash miss hit fetch deliver                }
-               "struct sess *"
-       }
+    # Possibly misnamed, not really part of the request
+    { req.hash
+       WO HASH
+       {               hash                                       error }
+       "struct sess *"
+    }
+    { req.backend
+       RW BACKEND
+       {recv pipe pass hash miss hit fetch                        error }
+       "struct sess *"
+    }
+    { req.restarts
+       RO INT
+       {recv pipe pass hash miss hit fetch deliver                error }
+       "const struct sess *"
+    }
+    { req.grace
+       RW TIME
+       {recv pipe pass hash miss hit fetch deliver                error }
+       "struct sess *"
+    }
 
-       # Request sent to backend
-       { bereq.request
-               RW STRING
-               {     pipe pass      miss     fetch                        }
-               "const struct sess *"
-       }
-       { bereq.url
-               RW STRING
-               {     pipe pass      miss     fetch                        }
-               "const struct sess *"
-       }
-       { bereq.proto
-               RW STRING
-               {     pipe pass      miss     fetch                        }
-               "const struct sess *"
-       }
-       { bereq.http.
-               RW HDR_BEREQ
-               {     pipe pass      miss     fetch                        }
-               "const struct sess *"
-       }
+    { req.xid
+       RO STRING
+       {recv pipe pass hash miss hit fetch deliver                error}
+       "struct sess *"
+    }
 
-       # The (possibly) cached object
-       { obj.proto
-               RW STRING
-               {                         hit fetch                        }
-               "const struct sess *"
-       }
-       { obj.status
-               RW INT
-               {                             fetch                        }
-               "const struct sess *"
-       }
-       { obj.response
-               RW STRING
-               {                             fetch                        }
-               "const struct sess *"
-       }
-       { obj.http.
-               RW HDR_OBJ
-               {                         hit fetch                        }
-               "const struct sess *"
-       }
+    # Request sent to backend
+    { bereq.request
+       RW STRING
+       {     pipe pass      miss     fetch                        }
+       "const struct sess *"
+    }
+    { bereq.url
+       RW STRING
+       {     pipe pass      miss     fetch                        }
+       "const struct sess *"
+    }
+    { bereq.proto
+       RW STRING
+       {     pipe pass      miss     fetch                        }
+       "const struct sess *"
+    }
+    { bereq.http.
+       RW HDR_BEREQ
+       {     pipe pass      miss     fetch                        }
+       "const struct sess *"
+    }
 
-       { obj.valid
-               RW BOOL
-               {                         hit fetch         discard timeout}
-               "const struct sess *"
-       }
-       { obj.cacheable
-               RW BOOL
-               {                         hit fetch         discard timeout}
-               "const struct sess *"
-       }
-       { obj.ttl
-               RW TIME
-               {                         hit fetch         discard timeout}
-               "const struct sess *"
-       }
-       { obj.grace
-               RW TIME
-               {                         hit fetch         discard timeout}
-               "const struct sess *"
-       }
-       { obj.prefetch
-               RW RTIME
-               { fetch prefetch }
-               "const struct sess *"
-       }
-       { obj.lastuse
-               RO TIME
-               {                         hit fetch deliver discard timeout}
-               "const struct sess *"
-       }
-       { obj.hash
-               RO STRING
-               {                    miss hit fetch deliver                }
-               "const struct sess *"
-       }
+    # The (possibly) cached object
+    { obj.proto
+       RW STRING
+       {                         hit fetch                         error}
+       "const struct sess *"
+    }
+    { obj.status
+       RW INT
+       {                             fetch                         error}
+       "const struct sess *"
+    }
+    { obj.response
+       RW STRING
+       {                             fetch                         error}
+       "const struct sess *"
+    }
+    { obj.http.
+       RW HDR_OBJ
+       {                         hit fetch                         error}
+       "const struct sess *"
+    }
 
-       # The response we send back
-       { resp.proto
-               RW STRING
-               {                                   deliver                }
-               "const struct sess *"
-       }
-       { resp.status
-               RW INT
-               {                                   deliver                }
-               "const struct sess *"
-       }
-       { resp.response
-               RW STRING
-               {                                   deliver                }
-               "const struct sess *"
-       }
-       { resp.http.
-               RW HDR_RESP
-               {                                   deliver                }
-               "const struct sess *"
-       }
+    { obj.valid
+       RW BOOL
+       {                         hit fetch         discard timeout error}
+       "const struct sess *"
+    }
+    { obj.cacheable
+       RW BOOL
+       {                         hit fetch         discard timeout error}
+       "const struct sess *"
+    }
+    { obj.ttl
+       RW TIME
+       {                         hit fetch         discard timeout error}
+       "const struct sess *"
+    }
+    { obj.grace
+       RW TIME
+       {                         hit fetch         discard timeout error}
+       "const struct sess *"
+    }
+    { obj.prefetch
+       RW RTIME
+       { fetch prefetch }
+       "const struct sess *"
+    }
+    { obj.lastuse
+       RO TIME
+       {                         hit fetch deliver discard timeout error}
+       "const struct sess *"
+    }
+    { obj.hash
+       RO STRING
+       {                    miss hit fetch deliver                 error}
+       "const struct sess *"
+    }
 
-       # Miscellaneous
-       # XXX: I'm not happy about this one.  All times should be relative
-       # XXX: or delta times in VCL programs, so this shouldn't be needed /phk
-       { now
-               RO TIME
-               {recv pipe pass hash miss hit fetch deliver discard timeout}
-               "const struct sess *"
-       }
-       { backend.health        RO INT
-               {recv pipe pass hash miss hit fetch deliver discard timeout}
-               "const struct sess *"
-       }
+    # The response we send back
+    { resp.proto
+       RW STRING
+       {                                   deliver                }
+       "const struct sess *"
+    }
+    { resp.status
+       RW INT
+       {                                   deliver                }
+       "const struct sess *"
+    }
+    { resp.response
+       RW STRING
+       {                                   deliver                }
+       "const struct sess *"
+    }
+    { resp.http.
+       RW HDR_RESP
+       {                                   deliver                }
+       "const struct sess *"
+    }
+
+    # Miscellaneous
+    # XXX: I'm not happy about this one.  All times should be relative
+    # XXX: or delta times in VCL programs, so this shouldn't be needed /phk
+    { now
+           RO TIME
+           {recv pipe pass hash miss hit fetch deliver discard timeout}
+           "const struct sess *"
+    }
+    { backend.health   RO INT
+           {recv pipe pass hash miss hit fetch deliver discard timeout}
+           "const struct sess *"
+    }
 
 }
 
index f674d5ff03588ad416d19c6c89ec80c66d18902d..754fa96573dccd1e348fca352f72f671017ba7da 100644 (file)
@@ -16,77 +16,84 @@ struct var vcc_vars[] = {
            NULL,
            V_RO,
            0,
-           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR
        },
        { "server.ip", IP, 9,
            "VRT_r_server_ip(sp)",
            NULL,
            V_RO,
            0,
-           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR
        },
        { "server.port", INT, 11,
            "VRT_r_server_port(sp)",
            NULL,
            V_RO,
            0,
-           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR
        },
        { "req.request", STRING, 11,
            "VRT_r_req_request(sp)",
            "VRT_l_req_request(sp, ",
            V_RW,
            0,
-           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH
+           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
        },
        { "req.url", STRING, 7,
            "VRT_r_req_url(sp)",
            "VRT_l_req_url(sp, ",
            V_RW,
            0,
-           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH
+           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
        },
        { "req.proto", STRING, 9,
            "VRT_r_req_proto(sp)",
            "VRT_l_req_proto(sp, ",
            V_RW,
            0,
-           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH
+           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
        },
        { "req.http.", HEADER, 9,
            "VRT_r_req_http_(sp)",
            "VRT_l_req_http_(sp, ",
            V_RW,
            "HDR_REQ",
-           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH
+           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
        },
        { "req.hash", HASH, 8,
            NULL,
            "VRT_l_req_hash(sp, ",
            V_WO,
            0,
-           VCL_MET_HASH
+           VCL_MET_HASH | VCL_MET_ERROR
        },
        { "req.backend", BACKEND, 11,
            "VRT_r_req_backend(sp)",
            "VRT_l_req_backend(sp, ",
            V_RW,
            0,
-           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH
+           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
        },
        { "req.restarts", INT, 12,
            "VRT_r_req_restarts(sp)",
            NULL,
            V_RO,
            0,
-           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR
        },
        { "req.grace", TIME, 9,
            "VRT_r_req_grace(sp)",
            "VRT_l_req_grace(sp, ",
            V_RW,
            0,
-           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR
+       },
+       { "req.xid", STRING, 7,
+           "VRT_r_req_xid(sp)",
+           NULL,
+           V_RO,
+           0,
+           VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR
        },
        { "bereq.request", STRING, 13,
            "VRT_r_bereq_request(sp)",
@@ -121,56 +128,56 @@ struct var vcc_vars[] = {
            "VRT_l_obj_proto(sp, ",
            V_RW,
            0,
-           VCL_MET_HIT | VCL_MET_FETCH
+           VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
        },
        { "obj.status", INT, 10,
            "VRT_r_obj_status(sp)",
            "VRT_l_obj_status(sp, ",
            V_RW,
            0,
-           VCL_MET_FETCH
+           VCL_MET_FETCH | VCL_MET_ERROR
        },
        { "obj.response", STRING, 12,
            "VRT_r_obj_response(sp)",
            "VRT_l_obj_response(sp, ",
            V_RW,
            0,
-           VCL_MET_FETCH
+           VCL_MET_FETCH | VCL_MET_ERROR
        },
        { "obj.http.", HEADER, 9,
            "VRT_r_obj_http_(sp)",
            "VRT_l_obj_http_(sp, ",
            V_RW,
            "HDR_OBJ",
-           VCL_MET_HIT | VCL_MET_FETCH
+           VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
        },
        { "obj.valid", BOOL, 9,
            "VRT_r_obj_valid(sp)",
            "VRT_l_obj_valid(sp, ",
            V_RW,
            0,
-           VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT
+           VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT | VCL_MET_ERROR
        },
        { "obj.cacheable", BOOL, 13,
            "VRT_r_obj_cacheable(sp)",
            "VRT_l_obj_cacheable(sp, ",
            V_RW,
            0,
-           VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT
+           VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT | VCL_MET_ERROR
        },
        { "obj.ttl", TIME, 7,
            "VRT_r_obj_ttl(sp)",
            "VRT_l_obj_ttl(sp, ",
            V_RW,
            0,
-           VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT
+           VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT | VCL_MET_ERROR
        },
        { "obj.grace", TIME, 9,
            "VRT_r_obj_grace(sp)",
            "VRT_l_obj_grace(sp, ",
            V_RW,
            0,
-           VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT
+           VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT | VCL_MET_ERROR
        },
        { "obj.prefetch", RTIME, 12,
            "VRT_r_obj_prefetch(sp)",
@@ -184,14 +191,14 @@ struct var vcc_vars[] = {
            NULL,
            V_RO,
            0,
-           VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_DISCARD | VCL_MET_TIMEOUT
+           VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_DISCARD | VCL_MET_TIMEOUT | VCL_MET_ERROR
        },
        { "obj.hash", STRING, 8,
            "VRT_r_obj_hash(sp)",
            NULL,
            V_RO,
            0,
-           VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+           VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR
        },
        { "resp.proto", STRING, 10,
            "VRT_r_resp_proto(sp)",