r778 - in trunk/varnish-cache: bin/varnishd include lib/libvcl

des at projects.linpro.no des at projects.linpro.no
Wed Aug 9 13:24:39 CEST 2006


Author: des
Date: 2006-08-09 13:24:39 +0200 (Wed, 09 Aug 2006)
New Revision: 778

Modified:
   trunk/varnish-cache/bin/varnishd/cache_vrt.c
   trunk/varnish-cache/include/vcl_returns.h
   trunk/varnish-cache/include/vrt_obj.h
   trunk/varnish-cache/lib/libvcl/vcc_compile.c
   trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
   trunk/varnish-cache/lib/libvcl/vcc_obj.c
Log:
Add support for using separate backends for separate virtual hosts:

 - remove the obj.backend variable, which is not connected to anything.
 - define a req.backend variable and implement l/r functions for it
 - complete / correct support for setting / comparing backend values

Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c	2006-08-09 11:22:55 UTC (rev 777)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c	2006-08-09 11:24:39 UTC (rev 778)
@@ -178,6 +178,22 @@
 
 /*--------------------------------------------------------------------*/
 
+void
+VRT_l_req_backend(struct sess *sp, struct backend *be)
+{
+	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	sp->backend = be;
+}
+
+struct backend *
+VRT_r_req_backend(struct sess *sp)
+{
+	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	return (sp->backend);
+}
+
+/*--------------------------------------------------------------------*/
+
 #define  VREQ(n1, n2)					\
 const char *						\
 VRT_r_req_##n1(struct sess *sp)				\

Modified: trunk/varnish-cache/include/vcl_returns.h
===================================================================
--- trunk/varnish-cache/include/vcl_returns.h	2006-08-09 11:22:55 UTC (rev 777)
+++ trunk/varnish-cache/include/vcl_returns.h	2006-08-09 11:24:39 UTC (rev 778)
@@ -1,5 +1,5 @@
 /*
- * $Id: vcc_gen_fixed_token.tcl 638 2006-08-04 10:54:30Z phk $
+ * $Id: /mirror/varnish/trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl 30751 2006-08-04T10:54:30.556113Z phk  $
  *
  * NB:  This file is machine generated, DO NOT EDIT!
  *

Modified: trunk/varnish-cache/include/vrt_obj.h
===================================================================
--- trunk/varnish-cache/include/vrt_obj.h	2006-08-09 11:22:55 UTC (rev 777)
+++ trunk/varnish-cache/include/vrt_obj.h	2006-08-09 11:24:39 UTC (rev 778)
@@ -1,5 +1,5 @@
 /*
- * $Id: vcc_gen_obj.tcl 555 2006-07-22 08:02:47Z phk $
+ * $Id: /mirror/varnish/trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 30495 2006-07-22T08:02:47.026287Z phk  $
  *
  * NB:  This file is machine generated, DO NOT EDIT!
  *
@@ -14,16 +14,18 @@
 void VRT_l_client_ip(struct sess *, const unsigned char *);
 const char * VRT_r_req_request(struct sess *);
 void VRT_l_req_request(struct sess *, const char *);
+const char * VRT_r_req_host(struct sess *);
+void VRT_l_req_host(struct sess *, const char *);
 const char * VRT_r_req_url(struct sess *);
 void VRT_l_req_url(struct sess *, const char *);
 const char * VRT_r_req_proto(struct sess *);
 void VRT_l_req_proto(struct sess *, const char *);
+struct backend * VRT_r_req_backend(struct sess *);
+void VRT_l_req_backend(struct sess *, struct backend *);
 double VRT_r_obj_valid(struct sess *);
 void VRT_l_obj_valid(struct sess *, double);
 double VRT_r_obj_cacheable(struct sess *);
 void VRT_l_obj_cacheable(struct sess *, double);
-struct backend * VRT_r_obj_backend(struct sess *);
-void VRT_l_obj_backend(struct sess *, struct backend *);
 double VRT_r_obj_ttl(struct sess *);
 void VRT_l_obj_ttl(struct sess *, double);
 const char * VRT_r_req_http_(struct sess *);

Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c	2006-08-09 11:22:55 UTC (rev 777)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c	2006-08-09 11:24:39 UTC (rev 778)
@@ -591,6 +591,13 @@
 }
 
 static void
+Cond_Backend(struct var *vp, struct tokenlist *tl)
+{
+
+	Fc(tl, 1, "%s\n", vp->rname);
+}
+
+static void
 Cond_2(struct tokenlist *tl)
 {
 	struct var *vp;
@@ -619,7 +626,7 @@
 		case IP:	L(tl, vcc_Cond_Ip(vp, tl)); break;
 		case STRING:	L(tl, Cond_String(vp, tl)); break;
 		case TIME:	L(tl, Cond_Int(vp, tl)); break;
-		/* XXX backend == */
+		case BACKEND:	L(tl, Cond_Backend(vp, tl)); break;
 		default:	
 			vsb_printf(tl->sb,
 			    "Variable '%s'"
@@ -834,8 +841,9 @@
 			if (tl->t->tok == '=') {
 				vcc_NextToken(tl);
 				AddRef(tl, tl->t, R_BACKEND);
-				Fc(tl, 0, "= &VGC_backend_%.*s;\n", PF(tl->t));
+				Fc(tl, 0, "VGC_backend_%.*s", PF(tl->t));
 				vcc_NextToken(tl);
+				Fc(tl, 0, ");\n");
 				break;
 			}
 			vsb_printf(tl->sb, "Illegal assignment operator ");

Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2006-08-09 11:22:55 UTC (rev 777)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2006-08-09 11:24:39 UTC (rev 778)
@@ -14,11 +14,12 @@
 set spobj {
 	{ client.ip	IP }
 	{ req.request	STRING }
+	{ req.host	STRING }
         { req.url	STRING }
         { req.proto	STRING }
+        { req.backend	BACKEND }
         { obj.valid	BOOL }
         { obj.cacheable	BOOL }
-        { obj.backend	BACKEND }
         { obj.ttl	TIME }
         { req.http.	HEADER }
 }

Modified: trunk/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_obj.c	2006-08-09 11:22:55 UTC (rev 777)
+++ trunk/varnish-cache/lib/libvcl/vcc_obj.c	2006-08-09 11:24:39 UTC (rev 778)
@@ -30,6 +30,10 @@
 	    "VRT_r_req_request(sp)",
 	    "VRT_l_req_request(sp, ",
 	},
+	{ "req.host", STRING, 8,
+	    "VRT_r_req_host(sp)",
+	    "VRT_l_req_host(sp, ",
+	},
 	{ "req.url", STRING, 7,
 	    "VRT_r_req_url(sp)",
 	    "VRT_l_req_url(sp, ",
@@ -38,6 +42,10 @@
 	    "VRT_r_req_proto(sp)",
 	    "VRT_l_req_proto(sp, ",
 	},
+	{ "req.backend", BACKEND, 11,
+	    "VRT_r_req_backend(sp)",
+	    "VRT_l_req_backend(sp, ",
+	},
 	{ "obj.valid", BOOL, 9,
 	    "VRT_r_obj_valid(sp)",
 	    "VRT_l_obj_valid(sp, ",
@@ -46,10 +54,6 @@
 	    "VRT_r_obj_cacheable(sp)",
 	    "VRT_l_obj_cacheable(sp, ",
 	},
-	{ "obj.backend", BACKEND, 11,
-	    "VRT_r_obj_backend(sp)",
-	    "VRT_l_obj_backend(sp, ",
-	},
 	{ "obj.ttl", TIME, 7,
 	    "VRT_r_obj_ttl(sp)",
 	    "VRT_l_obj_ttl(sp, ",
@@ -78,16 +82,18 @@
 	"void VRT_l_client_ip(struct sess *, const unsigned char *);\n"
 	"const char * VRT_r_req_request(struct sess *);\n"
 	"void VRT_l_req_request(struct sess *, const char *);\n"
+	"const char * VRT_r_req_host(struct sess *);\n"
+	"void VRT_l_req_host(struct sess *, const char *);\n"
 	"const char * VRT_r_req_url(struct sess *);\n"
 	"void VRT_l_req_url(struct sess *, const char *);\n"
 	"const char * VRT_r_req_proto(struct sess *);\n"
 	"void VRT_l_req_proto(struct sess *, const char *);\n"
+	"struct backend * VRT_r_req_backend(struct sess *);\n"
+	"void VRT_l_req_backend(struct sess *, struct backend *);\n"
 	"double VRT_r_obj_valid(struct sess *);\n"
 	"void VRT_l_obj_valid(struct sess *, double);\n"
 	"double VRT_r_obj_cacheable(struct sess *);\n"
 	"void VRT_l_obj_cacheable(struct sess *, double);\n"
-	"struct backend * VRT_r_obj_backend(struct sess *);\n"
-	"void VRT_l_obj_backend(struct sess *, struct backend *);\n"
 	"double VRT_r_obj_ttl(struct sess *);\n"
 	"void VRT_l_obj_ttl(struct sess *, double);\n"
 	"const char * VRT_r_req_http_(struct sess *);\n"




More information about the varnish-commit mailing list