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
0cdfda93
Commit
0cdfda93
authored
Sep 11, 2013
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Now that directors are in VMODs and VCL_BACKEND is a bona fide
VCL type, we can simplify the VCC backend code somewhat.
parent
f217f3eb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
100 deletions
+46
-100
vcc_backend.c
lib/libvcl/vcc_backend.c
+32
-94
vcc_compile.c
lib/libvcl/vcc_compile.c
+0
-1
vcc_compile.h
lib/libvcl/vcc_compile.h
+2
-3
vcc_parse.c
lib/libvcl/vcc_parse.c
+12
-2
No files found.
lib/libvcl/vcc_backend.c
View file @
0cdfda93
...
@@ -26,26 +26,6 @@
...
@@ -26,26 +26,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* SUCH DAMAGE.
*
*
* A necessary explanation of a convoluted policy:
*
* In VCL we have backends and directors.
*
* In VRT we have directors which reference (a number of) backend hosts.
*
* A VCL backend therefore has an implicit director of type "simple" created
* by the compiler, but not visible in VCL.
*
* A VCL backend is a "named host", these can be referenced by name from
* VCL directors, but not from VCL backends.
*
* The reason for this quasimadness is that we want to collect statistics
* for each actual kickable hardware backend machine, but we want to be
* able to refer to them multiple times in different directors.
*
* At the same time, we do not want to force users to declare each backend
* host with a name, if all they want to do is put it into a director, so
* backend hosts can be declared inline in the director, in which case
* its identity is the director and its numerical index therein.
*/
*/
#include "config.h"
#include "config.h"
...
@@ -57,13 +37,6 @@
...
@@ -57,13 +37,6 @@
#include "vss.h"
#include "vss.h"
struct
host
{
VTAILQ_ENTRY
(
host
)
list
;
struct
token
*
name
;
char
*
vgcname
;
};
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
* Struct sockaddr is not really designed to be a compile time
* Struct sockaddr is not really designed to be a compile time
* initialized data structure, so we encode it as a byte-string
* initialized data structure, so we encode it as a byte-string
...
@@ -293,7 +266,7 @@ vcc_ParseProbe(struct vcc *tl)
...
@@ -293,7 +266,7 @@ vcc_ParseProbe(struct vcc *tl)
*/
*/
static
void
static
void
vcc_ParseHostDef
(
struct
vcc
*
tl
,
int
serial
,
const
char
*
vgcnam
e
)
vcc_ParseHostDef
(
struct
vcc
*
tl
,
const
struct
token
*
t_b
e
)
{
{
struct
token
*
t_field
;
struct
token
*
t_field
;
struct
token
*
t_host
=
NULL
;
struct
token
*
t_host
=
NULL
;
...
@@ -303,6 +276,9 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname)
...
@@ -303,6 +276,9 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname)
struct
vsb
*
vsb
;
struct
vsb
*
vsb
;
unsigned
u
;
unsigned
u
;
double
t
;
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
);
Fh
(
tl
,
1
,
"
\n
#define VGC_backend_%s %d
\n
"
,
vgcname
,
tl
->
ndirector
);
...
@@ -326,9 +302,7 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname)
...
@@ -326,9 +302,7 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname)
Fb
(
tl
,
0
,
"
\n
static const struct vrt_backend vgc_dir_priv_%s = {
\n
"
,
Fb
(
tl
,
0
,
"
\n
static const struct vrt_backend vgc_dir_priv_%s = {
\n
"
,
vgcname
);
vgcname
);
Fb
(
tl
,
0
,
"
\t
.vcl_name =
\"
%.*s"
,
PF
(
tl
->
t_dir
));
Fb
(
tl
,
0
,
"
\t
.vcl_name =
\"
%.*s"
,
PF
(
t_be
));
if
(
serial
>=
0
)
Fb
(
tl
,
0
,
"[%d]"
,
serial
);
Fb
(
tl
,
0
,
"
\"
,
\n
"
);
Fb
(
tl
,
0
,
"
\"
,
\n
"
);
/* Check for old syntax */
/* Check for old syntax */
...
@@ -450,86 +424,52 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname)
...
@@ -450,86 +424,52 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname)
tl
->
ndirector
++
;
tl
->
ndirector
++
;
}
}
/*--------------------------------------------------------------------
* Tell rest of compiler about a backend
*/
static
void
vcc_DefBackend
(
struct
vcc
*
tl
,
const
struct
token
*
nm
)
{
struct
symbol
*
sym
;
sym
=
VCC_GetSymbolTok
(
tl
,
nm
,
SYM_BACKEND
);
AN
(
sym
);
if
(
sym
->
ndef
>
0
)
{
VSB_printf
(
tl
->
sb
,
"Backend %.*s redefined
\n
"
,
PF
(
nm
));
vcc_ErrWhere
(
tl
,
nm
);
return
;
}
sym
->
fmt
=
BACKEND
;
sym
->
eval
=
vcc_Eval_Backend
;
sym
->
ndef
++
;
}
/*--------------------------------------------------------------------
* Parse a plain backend aka a simple director
*/
static
void
vcc_ParseSimpleDirector
(
struct
vcc
*
tl
)
{
struct
host
*
h
;
char
vgcname
[
BUFSIZ
];
h
=
TlAlloc
(
tl
,
sizeof
*
h
);
h
->
name
=
tl
->
t_dir
;
vcc_DefBackend
(
tl
,
tl
->
t_dir
);
ERRCHK
(
tl
);
sprintf
(
vgcname
,
"_%.*s"
,
PF
(
h
->
name
));
h
->
vgcname
=
TlAlloc
(
tl
,
strlen
(
vgcname
)
+
1
);
strcpy
(
h
->
vgcname
,
vgcname
);
vcc_ParseHostDef
(
tl
,
-
1
,
vgcname
);
ERRCHK
(
tl
);
VTAILQ_INSERT_TAIL
(
&
tl
->
hosts
,
h
,
list
);
}
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
* Parse directors and backends
* Parse directors and backends
*/
*/
void
void
vcc_Parse
Director
(
struct
vcc
*
tl
)
vcc_Parse
Backend
(
struct
vcc
*
tl
)
{
{
struct
token
*
t_first
;
struct
token
*
t_first
,
*
t_be
;
int
isfirst
;
int
isfirst
;
struct
symbol
*
sym
;
t_first
=
tl
->
t
;
t_first
=
tl
->
t
;
vcc_NextToken
(
tl
);
/* ID:
director |
backend */
vcc_NextToken
(
tl
);
/* ID: backend */
vcc_ExpectCid
(
tl
);
/* ID: name */
vcc_ExpectCid
(
tl
);
/* ID: name */
ERRCHK
(
tl
);
ERRCHK
(
tl
);
if
(
tl
->
t
->
e
-
tl
->
t
->
b
>
64
)
{
if
(
tl
->
t
->
e
-
tl
->
t
->
b
>
MAX_BACKEND_NAME
)
{
VSB_printf
(
tl
->
sb
,
VSB_printf
(
tl
->
sb
,
"Name of %.*s too long (max 64, is %zu):
\n
"
,
"Name of %.*s too long (max %d, is %zu):
\n
"
,
PF
(
t_first
),
(
size_t
)(
tl
->
t
->
e
-
tl
->
t
->
b
));
PF
(
t_first
),
MAX_BACKEND_NAME
,
(
size_t
)(
tl
->
t
->
e
-
tl
->
t
->
b
));
vcc_ErrWhere
(
tl
,
tl
->
t
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
return
;
return
;
}
}
tl
->
t_dir
=
tl
->
t
;
vcc_NextToken
(
tl
);
t_be
=
tl
->
t
;
vcc_NextToken
(
tl
);
isfirst
=
tl
->
ndirector
;
isfirst
=
tl
->
ndirector
;
if
(
vcc_IdIs
(
t_first
,
"backend"
))
{
vcc_ParseSimpleDirector
(
tl
);
sym
=
VCC_GetSymbolTok
(
tl
,
t_be
,
SYM_BACKEND
);
}
else
{
AN
(
sym
);
VSB_printf
(
tl
->
sb
,
if
(
sym
->
ndef
>
0
)
{
"
\n
directors are now in VMOD.directors
\n
"
);
VSB_printf
(
tl
->
sb
,
"Backend %.*s redefined
\n
"
,
PF
(
t_be
)
);
vcc_ErrWhere
(
tl
,
t_
first
);
vcc_ErrWhere
(
tl
,
t_
be
);
return
;
return
;
}
}
sym
->
fmt
=
BACKEND
;
sym
->
eval
=
vcc_Eval_Backend
;
sym
->
ndef
++
;
ERRCHK
(
tl
);
vcc_ParseHostDef
(
tl
,
t_be
);
ERRCHK
(
tl
);
if
(
tl
->
err
)
{
if
(
tl
->
err
)
{
VSB_printf
(
tl
->
sb
,
VSB_printf
(
tl
->
sb
,
"
\n
In %.*s specification starting at:
\n
"
,
PF
(
t_first
));
"
\n
In %.*s specification starting at:
\n
"
,
PF
(
t_first
));
...
@@ -537,10 +477,8 @@ vcc_ParseDirector(struct vcc *tl)
...
@@ -537,10 +477,8 @@ vcc_ParseDirector(struct vcc *tl)
return
;
return
;
}
}
if
(
isfirst
==
1
||
vcc_IdIs
(
t
l
->
t_dir
,
"default"
))
{
if
(
isfirst
==
1
||
vcc_IdIs
(
t
_be
,
"default"
))
{
tl
->
defaultdir
=
tl
->
ndirector
-
1
;
tl
->
defaultdir
=
tl
->
ndirector
-
1
;
tl
->
t_defaultdir
=
t
l
->
t_dir
;
tl
->
t_defaultdir
=
t
_be
;
}
}
tl
->
t_dir
=
NULL
;
}
}
lib/libvcl/vcc_compile.c
View file @
0cdfda93
...
@@ -517,7 +517,6 @@ vcc_NewVcc(const struct vcc *tl0)
...
@@ -517,7 +517,6 @@ vcc_NewVcc(const struct vcc *tl0)
tl
->
err_unref
=
1
;
tl
->
err_unref
=
1
;
}
}
VTAILQ_INIT
(
&
tl
->
symbols
);
VTAILQ_INIT
(
&
tl
->
symbols
);
VTAILQ_INIT
(
&
tl
->
hosts
);
VTAILQ_INIT
(
&
tl
->
membits
);
VTAILQ_INIT
(
&
tl
->
membits
);
VTAILQ_INIT
(
&
tl
->
tokens
);
VTAILQ_INIT
(
&
tl
->
tokens
);
VTAILQ_INIT
(
&
tl
->
sources
);
VTAILQ_INIT
(
&
tl
->
sources
);
...
...
lib/libvcl/vcc_compile.h
View file @
0cdfda93
...
@@ -160,7 +160,6 @@ struct vcc {
...
@@ -160,7 +160,6 @@ struct vcc {
struct
tokenhead
tokens
;
struct
tokenhead
tokens
;
VTAILQ_HEAD
(,
source
)
sources
;
VTAILQ_HEAD
(,
source
)
sources
;
VTAILQ_HEAD
(,
membit
)
membits
;
VTAILQ_HEAD
(,
membit
)
membits
;
VTAILQ_HEAD
(,
host
)
hosts
;
unsigned
nsources
;
unsigned
nsources
;
struct
source
*
src
;
struct
source
*
src
;
struct
token
*
t
;
struct
token
*
t
;
...
@@ -191,7 +190,6 @@ struct vcc {
...
@@ -191,7 +190,6 @@ struct vcc {
int
defaultdir
;
int
defaultdir
;
struct
token
*
t_defaultdir
;
struct
token
*
t_defaultdir
;
struct
token
*
t_dir
;
unsigned
unique
;
unsigned
unique
;
unsigned
nvmodpriv
;
unsigned
nvmodpriv
;
...
@@ -228,10 +226,11 @@ void vcc_Acl_Hack(struct vcc *tl, char *b);
...
@@ -228,10 +226,11 @@ void vcc_Acl_Hack(struct vcc *tl, char *b);
int
vcc_ParseAction
(
struct
vcc
*
tl
);
int
vcc_ParseAction
(
struct
vcc
*
tl
);
/* vcc_backend.c */
/* vcc_backend.c */
#define MAX_BACKEND_NAME 64
struct
fld_spec
;
struct
fld_spec
;
void
vcc_ParseProbe
(
struct
vcc
*
tl
);
void
vcc_ParseProbe
(
struct
vcc
*
tl
);
void
vcc_Parse
Director
(
struct
vcc
*
tl
);
void
vcc_Parse
Backend
(
struct
vcc
*
tl
);
struct
fld_spec
*
vcc_FldSpec
(
struct
vcc
*
tl
,
const
char
*
first
,
...);
struct
fld_spec
*
vcc_FldSpec
(
struct
vcc
*
tl
,
const
char
*
first
,
...);
void
vcc_IsField
(
struct
vcc
*
tl
,
struct
token
**
t
,
struct
fld_spec
*
fs
);
void
vcc_IsField
(
struct
vcc
*
tl
,
struct
token
**
t
,
struct
fld_spec
*
fs
);
void
vcc_FieldsOk
(
struct
vcc
*
tl
,
const
struct
fld_spec
*
fs
);
void
vcc_FieldsOk
(
struct
vcc
*
tl
,
const
struct
fld_spec
*
fs
);
...
...
lib/libvcl/vcc_parse.c
View file @
0cdfda93
...
@@ -273,6 +273,16 @@ vcc_Function(struct vcc *tl)
...
@@ -273,6 +273,16 @@ vcc_Function(struct vcc *tl)
tl
->
curproc
=
NULL
;
tl
->
curproc
=
NULL
;
}
}
/*--------------------------------------------------------------------
*/
static
void
vcc_Director
(
struct
vcc
*
tl
)
{
VSB_printf
(
tl
->
sb
,
"
\n
directors are now in directors VMOD.
\n
"
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
}
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
* Top level of parser, recognize:
* Top level of parser, recognize:
* Inline C-code
* Inline C-code
...
@@ -290,8 +300,8 @@ static struct toplev {
...
@@ -290,8 +300,8 @@ static struct toplev {
}
toplev
[]
=
{
}
toplev
[]
=
{
{
"acl"
,
vcc_Acl
},
{
"acl"
,
vcc_Acl
},
{
"sub"
,
vcc_Function
},
{
"sub"
,
vcc_Function
},
{
"backend"
,
vcc_Parse
Director
},
{
"backend"
,
vcc_Parse
Backend
},
{
"director"
,
vcc_
Parse
Director
},
{
"director"
,
vcc_Director
},
{
"probe"
,
vcc_ParseProbe
},
{
"probe"
,
vcc_ParseProbe
},
{
"import"
,
vcc_ParseImport
},
{
"import"
,
vcc_ParseImport
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
...
...
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