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
04c40433
Commit
04c40433
authored
Sep 25, 2014
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use vrt_ctx also for init/fini
parent
6c29a9c8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
30 deletions
+43
-30
cache_backend.c
bin/varnishd/cache/cache_backend.c
+6
-5
cache_vcl.c
bin/varnishd/cache/cache_vcl.c
+13
-7
cache_vrt_vmod.c
bin/varnishd/cache/cache_vrt_vmod.c
+12
-8
vrt.h
include/vrt.h
+5
-3
generate.py
lib/libvcc/generate.py
+2
-2
vcc_backend.c
lib/libvcc/vcc_backend.c
+2
-2
vcc_compile.c
lib/libvcc/vcc_compile.c
+2
-2
vcc_vmod.c
lib/libvcc/vcc_vmod.c
+1
-1
No files found.
bin/varnishd/cache/cache_backend.c
View file @
04c40433
...
...
@@ -517,12 +517,12 @@ vdi_simple_finish(const struct director *d, struct worker *wrk,
/*--------------------------------------------------------------------*/
void
VRT_fini_dir
(
struct
cli
*
cli
,
struct
director
*
d
)
VRT_fini_dir
(
const
struct
vrt_ctx
*
ctx
,
struct
director
*
d
)
{
struct
vdi_simple
*
vs
;
(
void
)
cli
;
ASSERT_CLI
();
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CAST_OBJ_NOTNULL
(
vs
,
d
->
priv
,
VDI_SIMPLE_MAGIC
);
...
...
@@ -534,13 +534,14 @@ VRT_fini_dir(struct cli *cli, struct director *d)
}
void
VRT_init_dir
(
struct
cli
*
cli
,
struct
director
**
bp
,
int
idx
,
const
void
*
priv
)
VRT_init_dir
(
const
struct
vrt_ctx
*
ctx
,
struct
director
**
bp
,
int
idx
,
const
void
*
priv
)
{
const
struct
vrt_backend
*
t
;
struct
vdi_simple
*
vs
;
ASSERT_CLI
();
(
void
)
cli
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
)
;
t
=
priv
;
ALLOC_OBJ
(
vs
,
VDI_SIMPLE_MAGIC
);
...
...
@@ -557,7 +558,7 @@ VRT_init_dir(struct cli *cli, struct director **bp, int idx, const void *priv)
vs
->
vrt
=
t
;
vs
->
backend
=
VBE_AddBackend
(
cli
,
t
);
vs
->
backend
=
VBE_AddBackend
(
NULL
,
t
);
if
(
vs
->
vrt
->
probe
!=
NULL
)
VBP_Insert
(
vs
->
backend
,
vs
->
vrt
->
probe
,
vs
->
vrt
->
hosthdr
);
...
...
bin/varnishd/cache/cache_vcl.c
View file @
04c40433
...
...
@@ -180,9 +180,6 @@ VCL_Load(const char *fn, const char *name, struct cli *cli)
ASSERT_CLI
();
memset
(
&
ctx
,
0
,
sizeof
ctx
);
ctx
.
magic
=
VRT_CTX_MAGIC
;
vcl
=
vcl_find
(
name
);
if
(
vcl
!=
NULL
)
{
VCLI_Out
(
cli
,
"Config '%s' already loaded"
,
name
);
...
...
@@ -214,17 +211,26 @@ VCL_Load(const char *fn, const char *name, struct cli *cli)
FREE_OBJ
(
vcl
);
return
(
1
);
}
if
(
vcl
->
conf
->
init_vcl
(
cli
))
{
memset
(
&
ctx
,
0
,
sizeof
ctx
);
ctx
.
magic
=
VRT_CTX_MAGIC
;
ctx
.
method
=
VCL_MET_INIT
;
ctx
.
handling
=
&
hand
;
ctx
.
cli
=
cli
;
if
(
vcl
->
conf
->
init_vcl
(
&
ctx
))
{
VCLI_Out
(
cli
,
"VCL
\"
%s
\"
Failed to initialize"
,
name
);
vcl
->
conf
->
fini_vcl
(
&
ctx
);
(
void
)
dlclose
(
vcl
->
dlh
);
FREE_OBJ
(
vcl
);
return
(
1
);
}
ctx
.
method
=
VCL_MET_INIT
;
ctx
.
handling
=
&
hand
;
(
void
)
vcl
->
conf
->
init_func
(
&
ctx
);
if
(
hand
==
VCL_RET_FAIL
)
{
VCLI_Out
(
cli
,
"VCL
\"
%s
\"
vcl_init{} failed"
,
name
);
ctx
.
method
=
VCL_MET_FINI
;
(
void
)
vcl
->
conf
->
fini_func
(
&
ctx
);
vcl
->
conf
->
fini_vcl
(
&
ctx
);
(
void
)
dlclose
(
vcl
->
dlh
);
FREE_OBJ
(
vcl
);
return
(
1
);
...
...
@@ -264,7 +270,7 @@ VCL_Nuke(struct vcls *vcl)
ctx
.
handling
=
&
hand
;
(
void
)
vcl
->
conf
->
fini_func
(
&
ctx
);
assert
(
hand
==
VCL_RET_OK
);
vcl
->
conf
->
fini_vcl
(
NULL
);
vcl
->
conf
->
fini_vcl
(
&
ctx
);
free
(
vcl
->
name
);
(
void
)
dlclose
(
vcl
->
dlh
);
FREE_OBJ
(
vcl
);
...
...
bin/varnishd/cache/cache_vrt_vmod.c
View file @
04c40433
...
...
@@ -63,7 +63,7 @@ static VTAILQ_HEAD(,vmod) vmods = VTAILQ_HEAD_INITIALIZER(vmods);
int
VRT_Vmod_Init
(
void
**
hdl
,
void
*
ptr
,
int
len
,
const
char
*
nm
,
const
char
*
path
,
const
char
*
file_id
,
struct
cli
*
cli
)
const
char
*
path
,
const
char
*
file_id
,
const
struct
vrt_ctx
*
ctx
)
{
struct
vmod
*
v
;
const
struct
vmod_data
*
d
;
...
...
@@ -71,12 +71,14 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm,
void
*
dlhdl
;
ASSERT_CLI
();
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
AN
(
ctx
->
cli
);
dlhdl
=
dlopen
(
path
,
RTLD_NOW
|
RTLD_LOCAL
);
if
(
dlhdl
==
NULL
)
{
VCLI_Out
(
cli
,
"Loading VMOD %s from %s:
\n
"
,
nm
,
path
);
VCLI_Out
(
cli
,
"dlopen() failed: %s
\n
"
,
dlerror
());
VCLI_Out
(
cli
,
"Check child process permissions.
\n
"
);
VCLI_Out
(
c
tx
->
c
li
,
"Loading VMOD %s from %s:
\n
"
,
nm
,
path
);
VCLI_Out
(
c
tx
->
c
li
,
"dlopen() failed: %s
\n
"
,
dlerror
());
VCLI_Out
(
c
tx
->
c
li
,
"Check child process permissions.
\n
"
);
return
(
1
);
}
...
...
@@ -94,8 +96,9 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm,
if
(
d
==
NULL
||
d
->
file_id
==
NULL
||
strcmp
(
d
->
file_id
,
file_id
))
{
VCLI_Out
(
cli
,
"Loading VMOD %s from %s:
\n
"
,
nm
,
path
);
VCLI_Out
(
cli
,
VCLI_Out
(
ctx
->
cli
,
"Loading VMOD %s from %s:
\n
"
,
nm
,
path
);
VCLI_Out
(
ctx
->
cli
,
"This is no longer the same file seen by"
" the VCL-compiler.
\n
"
);
(
void
)
dlclose
(
v
->
hdl
);
...
...
@@ -111,8 +114,9 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm,
d
->
proto
==
NULL
||
d
->
spec
==
NULL
||
d
->
abi
==
NULL
)
{
VCLI_Out
(
cli
,
"Loading VMOD %s from %s:
\n
"
,
nm
,
path
);
VCLI_Out
(
cli
,
"VMOD data is mangled.
\n
"
);
VCLI_Out
(
ctx
->
cli
,
"Loading VMOD %s from %s:
\n
"
,
nm
,
path
);
VCLI_Out
(
ctx
->
cli
,
"VMOD data is mangled.
\n
"
);
(
void
)
dlclose
(
v
->
hdl
);
FREE_OBJ
(
v
);
return
(
1
);
...
...
include/vrt.h
View file @
04c40433
...
...
@@ -89,6 +89,7 @@ struct vrt_ctx {
unsigned
method
;
unsigned
*
handling
;
struct
cli
*
cli
;
// Only in ...init()
struct
vsl_log
*
vsl
;
struct
VCL_conf
*
vcl
;
struct
ws
*
ws
;
...
...
@@ -223,15 +224,16 @@ void VRT_Rollback(const struct vrt_ctx *, const struct http *);
void
VRT_synth_page
(
const
struct
vrt_ctx
*
,
const
char
*
,
...);
/* Backend related */
void
VRT_init_dir
(
struct
cli
*
,
struct
director
**
,
int
idx
,
const
void
*
priv
);
void
VRT_fini_dir
(
struct
cli
*
,
struct
director
*
);
void
VRT_init_dir
(
const
struct
vrt_ctx
*
,
struct
director
**
,
int
idx
,
const
void
*
priv
);
void
VRT_fini_dir
(
const
struct
vrt_ctx
*
,
struct
director
*
);
/* Suckaddr related */
int
VRT_VSA_GetPtr
(
const
struct
suckaddr
*
sua
,
const
unsigned
char
**
dst
);
/* VMOD/Modules related */
int
VRT_Vmod_Init
(
void
**
hdl
,
void
*
ptr
,
int
len
,
const
char
*
nm
,
const
char
*
path
,
const
char
*
file_id
,
struct
cli
*
cli
);
const
char
*
path
,
const
char
*
file_id
,
const
struct
vrt_ctx
*
ctx
);
void
VRT_Vmod_Fini
(
void
**
hdl
);
struct
vmod_priv
;
...
...
lib/libvcc/generate.py
View file @
04c40433
...
...
@@ -929,8 +929,8 @@ struct ws;
struct cli;
struct worker;
typedef int vcl_init_f(
struct cli *
);
typedef void vcl_fini_f(
struct cli *
);
typedef int vcl_init_f(
const struct vrt_ctx *ctx
);
typedef void vcl_fini_f(
const struct vrt_ctx *ctx
);
typedef int vcl_func_f(const struct vrt_ctx *ctx);
"""
)
...
...
lib/libvcc/vcc_backend.c
View file @
04c40433
...
...
@@ -423,9 +423,9 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be)
ifp
=
New_IniFin
(
tl
);
VSB_printf
(
ifp
->
ini
,
"
\t
VRT_init_dir(c
li
, VCL_conf.director,
\n
"
"
\t
VRT_init_dir(c
tx
, VCL_conf.director,
\n
"
"
\t
VGC_backend_%s, &vgc_dir_priv_%s);"
,
vgcname
,
vgcname
);
VSB_printf
(
ifp
->
fin
,
"
\t
VRT_fini_dir(c
li
, VGCDIR(%s));"
,
vgcname
);
VSB_printf
(
ifp
->
fin
,
"
\t
VRT_fini_dir(c
tx
, VGCDIR(%s));"
,
vgcname
);
tl
->
ndirector
++
;
}
...
...
lib/libvcc/vcc_compile.c
View file @
04c40433
...
...
@@ -302,7 +302,7 @@ EmitInitFunc(const struct vcc *tl)
{
struct
inifin
*
p
;
Fc
(
tl
,
0
,
"
\n
static int
\n
VGC_Init(
struct cli *cli
)
\n
{
\n\n
"
);
Fc
(
tl
,
0
,
"
\n
static int
\n
VGC_Init(
const struct vrt_ctx *ctx
)
\n
{
\n\n
"
);
VTAILQ_FOREACH
(
p
,
&
tl
->
inifin
,
list
)
{
AZ
(
VSB_finish
(
p
->
ini
));
if
(
VSB_len
(
p
->
ini
))
...
...
@@ -319,7 +319,7 @@ EmitFiniFunc(const struct vcc *tl)
{
struct
inifin
*
p
;
Fc
(
tl
,
0
,
"
\n
static void
\n
VGC_Fini(
struct cli *cli
)
\n
{
\n\n
"
);
Fc
(
tl
,
0
,
"
\n
static void
\n
VGC_Fini(
const struct vrt_ctx *ctx
)
\n
{
\n\n
"
);
VTAILQ_FOREACH_REVERSE
(
p
,
&
tl
->
inifin
,
inifinhead
,
list
)
{
AZ
(
VSB_finish
(
p
->
fin
));
...
...
lib/libvcc/vcc_vmod.c
View file @
04c40433
...
...
@@ -177,7 +177,7 @@ vcc_ParseImport(struct vcc *tl)
AN
(
vmd
);
AN
(
vmd
->
file_id
);
VSB_printf
(
ifp
->
ini
,
"
\t
\"
%s
\"
,
\n
"
,
vmd
->
file_id
);
VSB_printf
(
ifp
->
ini
,
"
\t
c
li
))
\n
"
);
VSB_printf
(
ifp
->
ini
,
"
\t
c
tx
))
\n
"
);
VSB_printf
(
ifp
->
ini
,
"
\t\t
return(1);"
);
/* XXX: zero the function pointer structure ?*/
...
...
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