Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
0aa8782e
Commit
0aa8782e
authored
Jun 01, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of the array of backend/directors in the compiled VCL.
parent
256504c5
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
41 additions
and
41 deletions
+41
-41
cache_req_fsm.c
bin/varnishd/cache/cache_req_fsm.c
+1
-1
r00916.vtc
bin/varnishtest/tests/r00916.vtc
+1
-1
v00016.vtc
bin/varnishtest/tests/v00016.vtc
+9
-0
generate.py
lib/libvcc/generate.py
+1
-2
vcc_backend.c
lib/libvcc/vcc_backend.c
+12
-16
vcc_compile.c
lib/libvcc/vcc_compile.c
+3
-16
vcc_compile.h
lib/libvcc/vcc_compile.h
+2
-3
vcc_expr.c
lib/libvcc/vcc_expr.c
+12
-2
No files found.
bin/varnishd/cache/cache_req_fsm.c
View file @
0aa8782e
...
...
@@ -649,7 +649,7 @@ cnt_recv(struct worker *wrk, struct req *req)
/* By default we use the first backend */
AZ
(
req
->
director_hint
);
req
->
director_hint
=
req
->
vcl
->
director
[
0
]
;
req
->
director_hint
=
*
req
->
vcl
->
default_director
;
AN
(
req
->
director_hint
);
req
->
d_ttl
=
-
1
;
...
...
bin/varnishtest/tests/r00916.vtc
View file @
0aa8782e
...
...
@@ -5,7 +5,7 @@ server s1 {
txresp -body "FOO"
} -start
varnish v1 -errvcl {
Symbol not found: 's-1' (expected type BACKEND)
} {
varnish v1 -errvcl {
Backend not found: 's-1'
} {
backend b { .host = "127.0.0.1"; }
sub s1 {
}
...
...
bin/varnishtest/tests/v00016.vtc
View file @
0aa8782e
...
...
@@ -118,3 +118,12 @@ varnish v1 -errvcl {'bereq.between_bytes_timeout': cannot be set} {
set bereq.between_bytes_timeout = 10s;
}
}
varnish v1 -errvcl {Backend not found: 'c'} {
backend b { .host = "127.0.0.1"; }
sub vcl_backend_response {
if (beresp.backend == c) {
set beresp.ttl = 1h;
}
}
}
lib/libvcc/generate.py
View file @
0aa8782e
...
...
@@ -1060,8 +1060,7 @@ struct VCL_conf {
char *loaded_name;
struct director **director;
unsigned ndirector;
struct director **default_director;
struct vrt_ref *ref;
unsigned nref;
unsigned busy;
...
...
lib/libvcc/vcc_backend.c
View file @
0aa8782e
...
...
@@ -262,7 +262,7 @@ vcc_ParseProbe(struct vcc *tl)
*/
static
void
vcc_ParseHostDef
(
struct
vcc
*
tl
,
const
struct
token
*
t_be
)
vcc_ParseHostDef
(
struct
vcc
*
tl
,
const
struct
token
*
t_be
,
const
char
*
vgcname
)
{
struct
token
*
t_field
;
struct
token
*
t_host
=
NULL
;
...
...
@@ -273,11 +273,6 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be)
struct
vsb
*
vsb
;
unsigned
u
;
double
t
;
char
vgcname
[
MAX_BACKEND_NAME
+
8
];
sprintf
(
vgcname
,
"_%.*s"
,
PF
(
t_be
));
Fh
(
tl
,
1
,
"
\n
#define VGC_backend_%s %d
\n
"
,
vgcname
,
tl
->
ndirector
);
fs
=
vcc_FldSpec
(
tl
,
"!host"
,
...
...
@@ -415,15 +410,14 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be)
ifp
=
New_IniFin
(
tl
);
VSB_printf
(
ifp
->
ini
,
"
\t
VRT_init_vbe(ctx, &
VGCDIR(%s)
, &vgc_dir_priv_%s);"
,
"
\t
VRT_init_vbe(ctx, &
%s
, &vgc_dir_priv_%s);"
,
vgcname
,
vgcname
);
VSB_printf
(
ifp
->
fin
,
"
\t
VRT_fini_vbe(ctx, &
VGCDIR(%s)
, &vgc_dir_priv_%s);"
,
"
\t
VRT_fini_vbe(ctx, &
%s
, &vgc_dir_priv_%s);"
,
vgcname
,
vgcname
);
VSB_printf
(
ifp
->
event
,
"
\t
VRT_event_vbe(ctx, ev,
VGCDIR(%s)
, &vgc_dir_priv_%s);"
,
"
\t
VRT_event_vbe(ctx, ev,
%s
, &vgc_dir_priv_%s);"
,
vgcname
,
vgcname
);
tl
->
ndirector
++
;
}
/*--------------------------------------------------------------------
...
...
@@ -434,8 +428,8 @@ void
vcc_ParseBackend
(
struct
vcc
*
tl
)
{
struct
token
*
t_first
,
*
t_be
;
int
isfirst
;
struct
symbol
*
sym
;
char
vgcname
[
MAX_BACKEND_NAME
+
20
];
t_first
=
tl
->
t
;
vcc_NextToken
(
tl
);
/* ID: backend */
...
...
@@ -455,7 +449,8 @@ vcc_ParseBackend(struct vcc *tl)
t_be
=
tl
->
t
;
vcc_NextToken
(
tl
);
isfirst
=
tl
->
ndirector
;
sprintf
(
vgcname
,
"vgc_backend_%.*s"
,
PF
(
t_be
));
Fh
(
tl
,
0
,
"static struct director *%s;
\n
"
,
vgcname
);
sym
=
VCC_GetSymbolTok
(
tl
,
t_be
,
SYM_BACKEND
);
AN
(
sym
);
...
...
@@ -466,10 +461,11 @@ vcc_ParseBackend(struct vcc *tl)
}
sym
->
fmt
=
BACKEND
;
sym
->
eval
=
vcc_Eval_Backend
;
sym
->
eval_priv
=
TlDup
(
tl
,
vgcname
);
sym
->
ndef
++
;
ERRCHK
(
tl
);
vcc_ParseHostDef
(
tl
,
t_be
);
vcc_ParseHostDef
(
tl
,
t_be
,
vgcname
);
ERRCHK
(
tl
);
if
(
tl
->
err
)
{
...
...
@@ -479,8 +475,8 @@ vcc_ParseBackend(struct vcc *tl)
return
;
}
if
(
isfirst
==
1
||
vcc_IdIs
(
t_be
,
"default"
))
{
tl
->
default
dir
=
tl
->
ndirector
-
1
;
tl
->
t_default
di
r
=
t_be
;
if
(
tl
->
default_director
==
NULL
||
vcc_IdIs
(
t_be
,
"default"
))
{
tl
->
default
_director
=
sym
->
eval_priv
;
tl
->
t_default
_directo
r
=
t_be
;
}
}
lib/libvcc/vcc_compile.c
View file @
0aa8782e
...
...
@@ -387,14 +387,10 @@ EmitStruct(const struct vcc *tl)
}
Fc
(
tl
,
0
,
"};
\n
"
);
Fc
(
tl
,
0
,
"
\n
static struct director
\t
*directors[%d];
\n
"
,
tl
->
ndirector
);
Fc
(
tl
,
0
,
"
\n
const struct VCL_conf VCL_conf = {
\n
"
);
Fc
(
tl
,
0
,
"
\t
.magic = VCL_CONF_MAGIC,
\n
"
);
Fc
(
tl
,
0
,
"
\t
.event_vcl = VGC_Event,
\n
"
);
Fc
(
tl
,
0
,
"
\t
.ndirector = %d,
\n
"
,
tl
->
ndirector
);
Fc
(
tl
,
0
,
"
\t
.director = directors,
\n
"
);
Fc
(
tl
,
0
,
"
\t
.default_director = &%s,
\n
"
,
tl
->
default_director
);
Fc
(
tl
,
0
,
"
\t
.ref = VGC_ref,
\n
"
);
Fc
(
tl
,
0
,
"
\t
.nref = VGC_NREFS,
\n
"
);
Fc
(
tl
,
0
,
"
\t
.nsrc = %u,
\n
"
,
tl
->
nsources
);
...
...
@@ -535,7 +531,6 @@ vcc_NewVcc(const struct vcc *tl0)
VTAILQ_INIT
(
&
tl
->
sources
);
tl
->
nsources
=
0
;
tl
->
ndirector
=
1
;
/* General C code */
tl
->
fc
=
VSB_new_auto
();
...
...
@@ -600,7 +595,6 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp)
struct
vcc
*
tl
;
struct
symbol
*
sym
;
const
struct
var
*
v
;
struct
inifin
*
ifp
;
char
*
of
;
int
i
;
...
...
@@ -629,9 +623,6 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp)
Fh
(
tl
,
0
,
"/* ---===### VCC generated code ###===---*/
\n
"
);
Fh
(
tl
,
0
,
"
\n
extern const struct VCL_conf VCL_conf;
\n
"
);
/* Macro for accessing directors */
Fh
(
tl
,
0
,
"#define VGCDIR(n) VCL_conf.director[VGC_backend_##n]
\n
"
);
/* Register and lex the main source */
VTAILQ_INSERT_TAIL
(
&
tl
->
sources
,
sp
,
list
);
sp
->
idx
=
tl
->
nsources
++
;
...
...
@@ -665,7 +656,7 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp)
return
(
vcc_DestroyTokenList
(
tl
,
NULL
));
/* Check if we have any backends at all */
if
(
tl
->
ndirector
==
1
)
{
if
(
tl
->
default_director
==
NULL
)
{
VSB_printf
(
tl
->
sb
,
"No backends or directors found in VCL program, "
"at least one is necessary.
\n
"
);
...
...
@@ -674,11 +665,7 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp)
}
/* Configure the default director */
ifp
=
New_IniFin
(
tl
);
VSB_printf
(
ifp
->
ini
,
"
\t
VCL_conf.director[0] = VCL_conf.director[%d];"
,
tl
->
defaultdir
);
vcc_AddRef
(
tl
,
tl
->
t_defaultdir
,
SYM_BACKEND
);
vcc_AddRef
(
tl
,
tl
->
t_default_director
,
SYM_BACKEND
);
/* Check for orphans */
if
(
vcc_CheckReferences
(
tl
))
...
...
lib/libvcc/vcc_compile.h
View file @
0aa8782e
...
...
@@ -189,7 +189,6 @@ struct vcc {
struct
vsb
*
fm
[
VCL_MET_MAX
];
/* Method bodies */
struct
vsb
*
sb
;
int
err
;
int
ndirector
;
struct
proc
*
curproc
;
struct
proc
*
mprocs
[
VCL_MET_MAX
];
...
...
@@ -197,8 +196,8 @@ struct vcc {
int
nprobe
;
int
defaultdi
r
;
struct
token
*
t_default
di
r
;
const
char
*
default_directo
r
;
struct
token
*
t_default
_directo
r
;
unsigned
unique
;
...
...
lib/libvcc/vcc_expr.c
View file @
0aa8782e
...
...
@@ -508,7 +508,7 @@ vcc_Eval_Backend(struct vcc *tl, struct expr **e, const struct symbol *sym)
vcc_ExpectCid
(
tl
);
vcc_AddRef
(
tl
,
tl
->
t
,
SYM_BACKEND
);
*
e
=
vcc_mk_expr
(
BACKEND
,
"
VGCDIR(_%.*s)"
,
PF
(
tl
->
t
)
);
*
e
=
vcc_mk_expr
(
BACKEND
,
"
%s"
,
sym
->
eval_priv
);
(
*
e
)
->
constant
=
EXPR_VAR
;
/* XXX ? */
vcc_NextToken
(
tl
);
}
...
...
@@ -1129,6 +1129,7 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, enum var_type fmt)
const
char
*
re
;
const
char
*
not
;
struct
token
*
tk
;
struct
symbol
*
sym
;
*
e
=
NULL
;
...
...
@@ -1188,10 +1189,19 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, enum var_type fmt)
}
if
((
*
e
)
->
fmt
==
BACKEND
&&
(
tl
->
t
->
tok
==
T_EQ
||
tl
->
t
->
tok
==
T_NEQ
))
{
// XXX: just ask for a BACKEND expression instead ?
vcc_NextToken
(
tl
);
ExpectErr
(
tl
,
ID
);
sym
=
VCC_FindSymbol
(
tl
,
tl
->
t
,
SYM_BACKEND
);
if
(
sym
==
NULL
)
{
VSB_printf
(
tl
->
sb
,
"Backend not found: "
);
vcc_ErrToken
(
tl
,
tl
->
t
);
VSB_printf
(
tl
->
sb
,
"
\n
"
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
return
;
}
vcc_AddRef
(
tl
,
tl
->
t
,
SYM_BACKEND
);
bprintf
(
buf
,
"(
\v
1 %.*s
VGCDIR(_%.*s))"
,
PF
(
tk
),
PF
(
tl
->
t
)
);
bprintf
(
buf
,
"(
\v
1 %.*s
%s)"
,
PF
(
tk
),
sym
->
eval_priv
);
vcc_NextToken
(
tl
);
*
e
=
vcc_expr_edit
(
BOOL
,
buf
,
*
e
,
NULL
);
return
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment