From b4ddfedbdb97504932826cc69921bce8cb974d4d Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 25 Jul 2008 18:20:35 +0000 Subject: [PATCH] NB: Be careful with -trunk, this is a quite intrusive change. 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 --- varnish-cache/bin/varnishd/Makefile.am | 1 - varnish-cache/bin/varnishd/cache_center.c | 38 +- varnish-cache/bin/varnishd/cache_fetch.c | 4 - varnish-cache/bin/varnishd/cache_hash.c | 6 + varnish-cache/bin/varnishd/cache_synthetic.c | 126 ------- varnish-cache/bin/varnishd/cache_vrt.c | 18 + varnish-cache/bin/varnishd/mgt_vcc.c | 24 +- .../bin/varnishtest/tests/v00001.vtc | 3 +- varnish-cache/include/vcl.h | 1 + varnish-cache/include/vcl_returns.h | 6 +- varnish-cache/include/vrt_obj.h | 1 + varnish-cache/lib/libvcl/vcc_action.c | 17 +- varnish-cache/lib/libvcl/vcc_fixed_token.c | 2 + .../lib/libvcl/vcc_gen_fixed_token.tcl | 3 +- varnish-cache/lib/libvcl/vcc_gen_obj.tcl | 354 +++++++++--------- varnish-cache/lib/libvcl/vcc_obj.c | 49 +-- 16 files changed, 311 insertions(+), 342 deletions(-) delete mode 100644 varnish-cache/bin/varnishd/cache_synthetic.c diff --git a/varnish-cache/bin/varnishd/Makefile.am b/varnish-cache/bin/varnishd/Makefile.am index ebf01107..e8157315 100644 --- a/varnish-cache/bin/varnishd/Makefile.am +++ b/varnish-cache/bin/varnishd/Makefile.am @@ -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 \ diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 11ad722e..1b0ce8cd 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -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); } diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index e098dcf7..1202dde6 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -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__); diff --git a/varnish-cache/bin/varnishd/cache_hash.c b/varnish-cache/bin/varnishd/cache_hash.c index 6eba5876..f84cb4cd 100644 --- a/varnish-cache/bin/varnishd/cache_hash.c +++ b/varnish-cache/bin/varnishd/cache_hash.c @@ -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 index 91c13fee..00000000 --- a/varnish-cache/bin/varnishd/cache_synthetic.c +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * Copyright (c) 2007-2008 Linpro AS - * All rights reserved. - * - * Author: Dag-Erling Smørgrav - * - * 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 -#include - -#include - -#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, - "\n" - "\n" - "\n" - " \n" - " %03d %s\n", status, msg); - vsb_printf(&vsb, - " \n" - " \n" - "

Error %03d %s

\n", status, msg); - vsb_printf(&vsb, - "

%s

\n", reason); - vsb_printf(&vsb, - "

Guru Meditation:

\n" - "

XID: %u

\n", sp->xid); - vsb_printf(&vsb, - "
Varnish
\n" - " \n" - "\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"); -} diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index cf5919a5..ecbfb62f 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -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 * diff --git a/varnish-cache/bin/varnishd/mgt_vcc.c b/varnish-cache/bin/varnishd/mgt_vcc.c index 11533d08..372ff455 100644 --- a/varnish-cache/bin/varnishd/mgt_vcc.c +++ b/varnish-cache/bin/varnishd/mgt_vcc.c @@ -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" + "\n" + "\n" + "\n" + " \n" + " \"} obj.status \" \" obj.response {\"\n" + " \n" + " \n" + "

Error \"} obj.status \" \" obj.response {\"

\n" + "

\"} obj.response {\"

\n" + "

Guru Meditation:

\n" + "

XID: \"} req.xid {\"

\n" + "
Varnish
\n" + " \n" + "\n" + "\"};\n" + " deliver;\n" + "}\n" + "" ; /* * Prepare the compiler command line diff --git a/varnish-cache/bin/varnishtest/tests/v00001.vtc b/varnish-cache/bin/varnishtest/tests/v00001.vtc index 3292950d..c912bc8a 100644 --- a/varnish-cache/bin/varnishtest/tests/v00001.vtc +++ b/varnish-cache/bin/varnishtest/tests/v00001.vtc @@ -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 diff --git a/varnish-cache/include/vcl.h b/varnish-cache/include/vcl.h index 18d0479a..54745f1a 100644 --- a/varnish-cache/include/vcl.h +++ b/varnish-cache/include/vcl.h @@ -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; }; diff --git a/varnish-cache/include/vcl_returns.h b/varnish-cache/include/vcl_returns.h index d69c8d65..8359ecab 100644 --- a/varnish-cache/include/vcl_returns.h +++ b/varnish-cache/include/vcl_returns.h @@ -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 diff --git a/varnish-cache/include/vrt_obj.h b/varnish-cache/include/vrt_obj.h index 39675c25..aaab2386 100644 --- a/varnish-cache/include/vrt_obj.h +++ b/varnish-cache/include/vrt_obj.h @@ -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 *); diff --git a/varnish-cache/lib/libvcl/vcc_action.c b/varnish-cache/lib/libvcl/vcc_action.c index 05dcdddb..a32ee42f 100644 --- a/varnish-cache/lib/libvcl/vcc_action.c +++ b/varnish-cache/lib/libvcl/vcc_action.c @@ -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); diff --git a/varnish-cache/lib/libvcl/vcc_fixed_token.c b/varnish-cache/lib/libvcl/vcc_fixed_token.c index 89a5cb04..6c654659 100644 --- a/varnish-cache/lib/libvcl/vcc_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcc_fixed_token.c @@ -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"); diff --git a/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl b/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl index 1c23bb7a..bb077134 100755 --- a/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl +++ b/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl @@ -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 diff --git a/varnish-cache/lib/libvcl/vcc_gen_obj.tcl b/varnish-cache/lib/libvcl/vcc_gen_obj.tcl index ed06f538..a9b50025 100755 --- a/varnish-cache/lib/libvcl/vcc_gen_obj.tcl +++ b/varnish-cache/lib/libvcl/vcc_gen_obj.tcl @@ -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 @@ -35,185 +35,191 @@ # 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 *" + } } diff --git a/varnish-cache/lib/libvcl/vcc_obj.c b/varnish-cache/lib/libvcl/vcc_obj.c index f674d5ff..754fa965 100644 --- a/varnish-cache/lib/libvcl/vcc_obj.c +++ b/varnish-cache/lib/libvcl/vcc_obj.c @@ -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)", -- 2.39.5