]> err.no Git - varnish/commitdiff
Add support for using separate backends for separate virtual hosts:
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 9 Aug 2006 11:24:39 +0000 (11:24 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 9 Aug 2006 11:24:39 +0000 (11:24 +0000)
 - 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

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

varnish-cache/bin/varnishd/cache_vrt.c
varnish-cache/include/vcl_returns.h
varnish-cache/include/vrt_obj.h
varnish-cache/lib/libvcl/vcc_compile.c
varnish-cache/lib/libvcl/vcc_gen_obj.tcl
varnish-cache/lib/libvcl/vcc_obj.c

index 797407b19854b46bfcc902b029ee330db872012c..bf84a2539177d6bbee2b742860ad0ec2ca008f3c 100644 (file)
@@ -178,6 +178,22 @@ VOBJ(double, cacheable, cacheable)
 
 /*--------------------------------------------------------------------*/
 
+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)                                \
index b1814abe339b3ee530361bb0cf8a5a31f7fa1c20..bff0908bf9e3507c6b73d3acdefbf879efb2a3f0 100644 (file)
@@ -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!
  *
index 8bb9da11eccc56b0d6d63217851f0b393e7524f1..e2a8aa5cadcefe44e28bc22fa696b7f38579db33 100644 (file)
@@ -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 @@ const unsigned char * VRT_r_client_ip(struct sess *);
 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 *);
index 29345998db92949e259349f396cfa7a29e30a3ef..3654346308d7c8fff488297007d09c20dbf4d9e7 100644 (file)
@@ -590,6 +590,13 @@ Cond_Bool(struct var *vp, struct tokenlist *tl)
        Fc(tl, 1, "%s\n", vp->rname);
 }
 
+static void
+Cond_Backend(struct var *vp, struct tokenlist *tl)
+{
+
+       Fc(tl, 1, "%s\n", vp->rname);
+}
+
 static void
 Cond_2(struct tokenlist *tl)
 {
@@ -619,7 +626,7 @@ Cond_2(struct tokenlist *tl)
                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 @@ Action(struct tokenlist *tl)
                        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 ");
index 6c628f94c8303e0cb7c7f08441d5d646ffc38ccf..3f4d54d2a1d312aa311dbf96d273241095077ce5 100755 (executable)
@@ -14,11 +14,12 @@ set beobj {
 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 }
 }
index e91339167de9007e8ff4a168a15bc6e620ee9240..eff4974612743ba1769c50a9c1ab5fa633abfded 100644 (file)
@@ -30,6 +30,10 @@ struct var vcc_vars[] = {
            "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 @@ struct var vcc_vars[] = {
            "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 @@ struct var vcc_vars[] = {
            "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 @@ const char *vrt_obj_h =
        "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"