Commit b7cba38f authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

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

git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@778 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 856b638e
...@@ -178,6 +178,22 @@ VOBJ(double, cacheable, cacheable) ...@@ -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) \ #define VREQ(n1, n2) \
const char * \ const char * \
VRT_r_req_##n1(struct sess *sp) \ VRT_r_req_##n1(struct sess *sp) \
......
/* /*
* $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! * NB: This file is machine generated, DO NOT EDIT!
* *
......
/* /*
* $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! * NB: This file is machine generated, DO NOT EDIT!
* *
...@@ -14,16 +14,18 @@ const unsigned char * VRT_r_client_ip(struct sess *); ...@@ -14,16 +14,18 @@ const unsigned char * VRT_r_client_ip(struct sess *);
void VRT_l_client_ip(struct sess *, const unsigned char *); void VRT_l_client_ip(struct sess *, const unsigned char *);
const char * VRT_r_req_request(struct sess *); const char * VRT_r_req_request(struct sess *);
void VRT_l_req_request(struct sess *, const char *); 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 *); const char * VRT_r_req_url(struct sess *);
void VRT_l_req_url(struct sess *, const char *); void VRT_l_req_url(struct sess *, const char *);
const char * VRT_r_req_proto(struct sess *); const char * VRT_r_req_proto(struct sess *);
void VRT_l_req_proto(struct sess *, const char *); 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 *); double VRT_r_obj_valid(struct sess *);
void VRT_l_obj_valid(struct sess *, double); void VRT_l_obj_valid(struct sess *, double);
double VRT_r_obj_cacheable(struct sess *); double VRT_r_obj_cacheable(struct sess *);
void VRT_l_obj_cacheable(struct sess *, double); 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 *); double VRT_r_obj_ttl(struct sess *);
void VRT_l_obj_ttl(struct sess *, double); void VRT_l_obj_ttl(struct sess *, double);
const char * VRT_r_req_http_(struct sess *); const char * VRT_r_req_http_(struct sess *);
......
...@@ -590,6 +590,13 @@ Cond_Bool(struct var *vp, struct tokenlist *tl) ...@@ -590,6 +590,13 @@ Cond_Bool(struct var *vp, struct tokenlist *tl)
Fc(tl, 1, "%s\n", vp->rname); 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 static void
Cond_2(struct tokenlist *tl) Cond_2(struct tokenlist *tl)
{ {
...@@ -619,7 +626,7 @@ 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 IP: L(tl, vcc_Cond_Ip(vp, tl)); break;
case STRING: L(tl, Cond_String(vp, tl)); break; case STRING: L(tl, Cond_String(vp, tl)); break;
case TIME: L(tl, Cond_Int(vp, tl)); break; case TIME: L(tl, Cond_Int(vp, tl)); break;
/* XXX backend == */ case BACKEND: L(tl, Cond_Backend(vp, tl)); break;
default: default:
vsb_printf(tl->sb, vsb_printf(tl->sb,
"Variable '%s'" "Variable '%s'"
...@@ -834,8 +841,9 @@ Action(struct tokenlist *tl) ...@@ -834,8 +841,9 @@ Action(struct tokenlist *tl)
if (tl->t->tok == '=') { if (tl->t->tok == '=') {
vcc_NextToken(tl); vcc_NextToken(tl);
AddRef(tl, tl->t, R_BACKEND); 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); vcc_NextToken(tl);
Fc(tl, 0, ");\n");
break; break;
} }
vsb_printf(tl->sb, "Illegal assignment operator "); vsb_printf(tl->sb, "Illegal assignment operator ");
......
...@@ -14,11 +14,12 @@ set beobj { ...@@ -14,11 +14,12 @@ set beobj {
set spobj { set spobj {
{ client.ip IP } { client.ip IP }
{ req.request STRING } { req.request STRING }
{ req.host STRING }
{ req.url STRING } { req.url STRING }
{ req.proto STRING } { req.proto STRING }
{ req.backend BACKEND }
{ obj.valid BOOL } { obj.valid BOOL }
{ obj.cacheable BOOL } { obj.cacheable BOOL }
{ obj.backend BACKEND }
{ obj.ttl TIME } { obj.ttl TIME }
{ req.http. HEADER } { req.http. HEADER }
} }
......
...@@ -30,6 +30,10 @@ struct var vcc_vars[] = { ...@@ -30,6 +30,10 @@ struct var vcc_vars[] = {
"VRT_r_req_request(sp)", "VRT_r_req_request(sp)",
"VRT_l_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, { "req.url", STRING, 7,
"VRT_r_req_url(sp)", "VRT_r_req_url(sp)",
"VRT_l_req_url(sp, ", "VRT_l_req_url(sp, ",
...@@ -38,6 +42,10 @@ struct var vcc_vars[] = { ...@@ -38,6 +42,10 @@ struct var vcc_vars[] = {
"VRT_r_req_proto(sp)", "VRT_r_req_proto(sp)",
"VRT_l_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, { "obj.valid", BOOL, 9,
"VRT_r_obj_valid(sp)", "VRT_r_obj_valid(sp)",
"VRT_l_obj_valid(sp, ", "VRT_l_obj_valid(sp, ",
...@@ -46,10 +54,6 @@ struct var vcc_vars[] = { ...@@ -46,10 +54,6 @@ struct var vcc_vars[] = {
"VRT_r_obj_cacheable(sp)", "VRT_r_obj_cacheable(sp)",
"VRT_l_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, { "obj.ttl", TIME, 7,
"VRT_r_obj_ttl(sp)", "VRT_r_obj_ttl(sp)",
"VRT_l_obj_ttl(sp, ", "VRT_l_obj_ttl(sp, ",
...@@ -78,16 +82,18 @@ const char *vrt_obj_h = ...@@ -78,16 +82,18 @@ const char *vrt_obj_h =
"void VRT_l_client_ip(struct sess *, const unsigned char *);\n" "void VRT_l_client_ip(struct sess *, const unsigned char *);\n"
"const char * VRT_r_req_request(struct sess *);\n" "const char * VRT_r_req_request(struct sess *);\n"
"void VRT_l_req_request(struct sess *, const char *);\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" "const char * VRT_r_req_url(struct sess *);\n"
"void VRT_l_req_url(struct sess *, const char *);\n" "void VRT_l_req_url(struct sess *, const char *);\n"
"const char * VRT_r_req_proto(struct sess *);\n" "const char * VRT_r_req_proto(struct sess *);\n"
"void VRT_l_req_proto(struct sess *, const char *);\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" "double VRT_r_obj_valid(struct sess *);\n"
"void VRT_l_obj_valid(struct sess *, double);\n" "void VRT_l_obj_valid(struct sess *, double);\n"
"double VRT_r_obj_cacheable(struct sess *);\n" "double VRT_r_obj_cacheable(struct sess *);\n"
"void VRT_l_obj_cacheable(struct sess *, double);\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" "double VRT_r_obj_ttl(struct sess *);\n"
"void VRT_l_obj_ttl(struct sess *, double);\n" "void VRT_l_obj_ttl(struct sess *, double);\n"
"const char * VRT_r_req_http_(struct sess *);\n" "const char * VRT_r_req_http_(struct sess *);\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment