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
a535c1ae
Commit
a535c1ae
authored
Jan 30, 2018
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the name 'default' truly magic for both backends and probes.
parent
adc4d89e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
26 deletions
+50
-26
v00038.vtc
bin/varnishtest/tests/v00038.vtc
+5
-0
vcc_backend.c
lib/libvcc/vcc_backend.c
+30
-19
vcc_compile.c
lib/libvcc/vcc_compile.c
+1
-5
vcc_compile.h
lib/libvcc/vcc_compile.h
+3
-2
vcc_expr.c
lib/libvcc/vcc_expr.c
+11
-0
No files found.
bin/varnishtest/tests/v00038.vtc
View file @
a535c1ae
...
...
@@ -92,3 +92,8 @@ varnish v1 -errvcl "Mandatory field 'host' missing." {
.port = "NONE";
}
}
varnish v1 -errvcl "No default probe defined" {
backend b1 {
.probe = default;
}
}
lib/libvcc/vcc_backend.c
View file @
a535c1ae
...
...
@@ -35,6 +35,19 @@
#include "vcc_compile.h"
const
char
*
vcc_default_probe
(
struct
vcc
*
tl
)
{
if
(
tl
->
default_probe
!=
NULL
)
return
(
tl
->
default_probe
);
VSB_printf
(
tl
->
sb
,
"No default probe defined
\n
"
);
vcc_ErrToken
(
tl
,
tl
->
t
);
VSB_printf
(
tl
->
sb
,
" at
\n
"
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
return
(
""
);
}
/*--------------------------------------------------------------------
* Struct sockaddr is not really designed to be a compile time
* initialized data structure, so we encode it as a byte-string
...
...
@@ -390,13 +403,7 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname)
ERRCHK
(
tl
);
}
else
if
(
vcc_IdIs
(
t_field
,
"probe"
)
&&
tl
->
t
->
tok
==
ID
)
{
if
(
vcc_IdIs
(
tl
->
t
,
"default"
))
{
if
(
tl
->
default_probe
==
NULL
)
{
VSB_printf
(
tl
->
sb
,
"No default probe defined
\n
"
);
vcc_ErrToken
(
tl
,
tl
->
t
);
VSB_printf
(
tl
->
sb
,
" at
\n
"
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
}
(
void
)
vcc_default_probe
(
tl
);
}
else
{
pb
=
VCC_SymbolGet
(
tl
,
SYM_PROBE
,
"Probe not found"
,
XREF_REF
);
...
...
@@ -467,6 +474,7 @@ vcc_ParseBackend(struct vcc *tl)
{
struct
token
*
t_first
,
*
t_be
;
struct
symbol
*
sym
;
const
char
*
dn
;
tl
->
ndirector
++
;
t_first
=
tl
->
t
;
...
...
@@ -476,24 +484,27 @@ vcc_ParseBackend(struct vcc *tl)
ERRCHK
(
tl
);
t_be
=
tl
->
t
;
sym
=
VCC_HandleSymbol
(
tl
,
BACKEND
,
"vgc_backend"
);
ERRCHK
(
tl
);
Fh
(
tl
,
0
,
"
\n
static struct director *%s;
\n
"
,
sym
->
rname
);
vcc_ParseHostDef
(
tl
,
t_be
,
sym
->
rname
);
ERRCHK
(
tl
);
if
(
vcc_IdIs
(
tl
->
t
,
"default"
))
{
vcc_NextToken
(
tl
);
dn
=
"vgc_backend_default"
;
tl
->
default_director
=
dn
;
}
else
{
sym
=
VCC_HandleSymbol
(
tl
,
BACKEND
,
"vgc_backend"
);
ERRCHK
(
tl
);
dn
=
sym
->
rname
;
if
(
tl
->
default_director
==
NULL
)
{
tl
->
default_director
=
dn
;
sym
->
nref
++
;
}
}
Fh
(
tl
,
0
,
"
\n
static struct director *%s;
\n
"
,
dn
);
vcc_ParseHostDef
(
tl
,
t_be
,
dn
);
if
(
tl
->
err
)
{
VSB_printf
(
tl
->
sb
,
"
\n
In %.*s specification starting at:
\n
"
,
PF
(
t_first
));
vcc_ErrWhere
(
tl
,
t_first
);
return
;
}
if
(
tl
->
default_director
==
NULL
||
vcc_IdIs
(
t_be
,
"default"
))
tl
->
default_director
=
sym
;
}
void
...
...
lib/libvcc/vcc_compile.c
View file @
a535c1ae
...
...
@@ -415,8 +415,7 @@ EmitStruct(const struct vcc *tl)
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
.default_director = &%s,
\n
"
,
tl
->
default_director
->
rname
);
Fc
(
tl
,
0
,
"
\t
.default_director = &%s,
\n
"
,
tl
->
default_director
);
if
(
tl
->
default_probe
!=
NULL
)
Fc
(
tl
,
0
,
"
\t
.default_probe = %s,
\n
"
,
tl
->
default_probe
);
Fc
(
tl
,
0
,
"
\t
.ref = VGC_ref,
\n
"
);
...
...
@@ -611,9 +610,6 @@ vcc_CompileSource(struct vcc *tl, struct source *sp)
return
(
NULL
);
}
/* Refcount the default director & probe*/
tl
->
default_director
->
nref
++
;
/* Check for orphans */
if
(
vcc_CheckReferences
(
tl
))
return
(
NULL
);
...
...
lib/libvcc/vcc_compile.h
View file @
a535c1ae
...
...
@@ -219,8 +219,8 @@ struct vcc {
int
nprobe
;
int
ndirector
;
struct
symbol
*
default_director
;
c
har
*
default_probe
;
const
char
*
default_director
;
c
onst
char
*
default_probe
;
unsigned
unique
;
...
...
@@ -244,6 +244,7 @@ int vcc_ParseAction(struct vcc *tl);
/* vcc_backend.c */
struct
fld_spec
;
const
char
*
vcc_default_probe
(
struct
vcc
*
);
void
vcc_Backend_Init
(
struct
vcc
*
tl
);
void
vcc_ParseProbe
(
struct
vcc
*
tl
);
void
vcc_ParseBackend
(
struct
vcc
*
tl
);
...
...
lib/libvcc/vcc_expr.c
View file @
a535c1ae
...
...
@@ -648,6 +648,17 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
}
switch
(
tl
->
t
->
tok
)
{
case
ID
:
if
(
vcc_IdIs
(
tl
->
t
,
"default"
)
&&
fmt
==
PROBE
)
{
vcc_NextToken
(
tl
);
*
e
=
vcc_mk_expr
(
PROBE
,
"%s"
,
vcc_default_probe
(
tl
));
return
;
}
if
(
vcc_IdIs
(
tl
->
t
,
"default"
)
&&
fmt
==
BACKEND
)
{
vcc_NextToken
(
tl
);
*
e
=
vcc_mk_expr
(
BACKEND
,
"*(VCL_conf.default_director)"
);
return
;
}
sym
=
VCC_SymbolGet
(
tl
,
SYM_NONE
,
"Symbol not found"
,
XREF_NONE
);
ERRCHK
(
tl
);
...
...
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