r3027 - in trunk/varnish-cache: bin/varnishd bin/varnishtest/tests include lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Fri Jul 25 20:20:36 CEST 2008


Author: phk
Date: 2008-07-25 20:20:35 +0200 (Fri, 25 Jul 2008)
New Revision: 3027

Removed:
   trunk/varnish-cache/bin/varnishd/cache_synthetic.c
Modified:
   trunk/varnish-cache/bin/varnishd/Makefile.am
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_fetch.c
   trunk/varnish-cache/bin/varnishd/cache_hash.c
   trunk/varnish-cache/bin/varnishd/cache_vrt.c
   trunk/varnish-cache/bin/varnishd/mgt_vcc.c
   trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc
   trunk/varnish-cache/include/vcl.h
   trunk/varnish-cache/include/vcl_returns.h
   trunk/varnish-cache/include/vrt_obj.h
   trunk/varnish-cache/lib/libvcl/vcc_action.c
   trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
   trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
   trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
   trunk/varnish-cache/lib/libvcl/vcc_obj.c
Log:

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.




Modified: trunk/varnish-cache/bin/varnishd/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishd/Makefile.am	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/bin/varnishd/Makefile.am	2008-07-25 18:20:35 UTC (rev 3027)
@@ -31,7 +31,6 @@
 	cache_pipe.c \
 	cache_response.c \
 	cache_session.c \
-	cache_synthetic.c \
 	cache_vary.c \
 	cache_vcl.c \
 	cache_vrt.c \

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2008-07-25 18:20:35 UTC (rev 3027)
@@ -306,12 +306,40 @@
 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 @@
 	*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);
 	}
 

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c	2008-07-25 18:20:35 UTC (rev 3027)
@@ -331,11 +331,7 @@
 	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__);

Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c	2008-07-25 18:20:35 UTC (rev 3027)
@@ -104,6 +104,11 @@
 		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 @@
 		VTAILQ_INIT(&w->nobj->store);
 		VTAILQ_INIT(&w->nobj->esibits);
 		VSL_stats->n_object++;
+		
 	} else
 		CHECK_OBJ_NOTNULL(w->nobj, OBJECT_MAGIC);
 }

Deleted: trunk/varnish-cache/bin/varnishd/cache_synthetic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_synthetic.c	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/bin/varnishd/cache_synthetic.c	2008-07-25 18:20:35 UTC (rev 3027)
@@ -1,126 +0,0 @@
-/*-
- * Copyright (c) 2007-2008 Linpro AS
- * All rights reserved.
- *
- * Author: Dag-Erling Smørgrav <des at 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");
-}

Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c	2008-07-25 18:20:35 UTC (rev 3027)
@@ -467,6 +467,24 @@
 	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 *

Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c	2008-07-25 18:20:35 UTC (rev 3027)
@@ -158,7 +158,29 @@
     "}\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

Modified: trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc	2008-07-25 18:20:35 UTC (rev 3027)
@@ -38,11 +38,10 @@
 	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
 

Modified: trunk/varnish-cache/include/vcl.h
===================================================================
--- trunk/varnish-cache/include/vcl.h	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/include/vcl.h	2008-07-25 18:20:35 UTC (rev 3027)
@@ -46,4 +46,5 @@
 	vcl_func_f	*prefetch_func;
 	vcl_func_f	*timeout_func;
 	vcl_func_f	*discard_func;
+	vcl_func_f	*error_func;
 };

Modified: trunk/varnish-cache/include/vcl_returns.h
===================================================================
--- trunk/varnish-cache/include/vcl_returns.h	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/include/vcl_returns.h	2008-07-25 18:20:35 UTC (rev 3027)
@@ -43,10 +43,11 @@
 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 @@
 #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

Modified: trunk/varnish-cache/include/vrt_obj.h
===================================================================
--- trunk/varnish-cache/include/vrt_obj.h	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/include/vrt_obj.h	2008-07-25 18:20:35 UTC (rev 3027)
@@ -21,6 +21,7 @@
 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 *);

Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_action.c	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/lib/libvcl/vcc_action.c	2008-07-25 18:20:35 UTC (rev 3027)
@@ -94,15 +94,22 @@
 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);

Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2008-07-25 18:20:35 UTC (rev 3027)
@@ -278,6 +278,7 @@
 	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 @@
 	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");

Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl	2008-07-25 18:20:35 UTC (rev 3027)
@@ -41,10 +41,11 @@
 	{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

Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2008-07-25 18:20:35 UTC (rev 3027)
@@ -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,186 +35,192 @@
 # 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 *"
+    }
+
 }
 
 set tt(IP)		"struct sockaddr *"

Modified: trunk/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_obj.c	2008-07-25 16:33:04 UTC (rev 3026)
+++ trunk/varnish-cache/lib/libvcl/vcc_obj.c	2008-07-25 18:20:35 UTC (rev 3027)
@@ -16,78 +16,85 @@
 	    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)",
 	    "VRT_l_bereq_request(sp, ",
@@ -121,56 +128,56 @@
 	    "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 @@
 	    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)",




More information about the varnish-commit mailing list