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
f9f26156
Commit
f9f26156
authored
Feb 11, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eliminate special case for mgt_vcc_default() using the cli we have
already set up in mgt_main.
parent
b87d45ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
44 deletions
+34
-44
mgt.h
bin/varnishd/mgt/mgt.h
+2
-1
mgt_main.c
bin/varnishd/mgt/mgt_main.c
+9
-6
mgt_vcc.c
bin/varnishd/mgt/mgt_vcc.c
+23
-37
No files found.
bin/varnishd/mgt/mgt.h
View file @
f9f26156
...
...
@@ -118,7 +118,8 @@ void STV_Config_Transient(void);
/* mgt_vcc.c */
void
mgt_vcc_init
(
void
);
unsigned
mgt_vcc_default
(
const
char
*
bflag
,
const
char
*
vcl
,
int
Cflag
);
void
mgt_vcc_default
(
struct
cli
*
,
const
char
*
b_arg
,
const
char
*
vclsrc
,
int
Cflag
);
int
mgt_push_vcls_and_start
(
unsigned
*
status
,
char
**
p
);
int
mgt_has_vcl
(
void
);
extern
char
*
mgt_cc_cmd
;
...
...
bin/varnishd/mgt/mgt_main.c
View file @
f9f26156
...
...
@@ -656,13 +656,16 @@ main(int argc, char * const *argv)
P_arg
,
strerror
(
errno
));
if
(
b_arg
!=
NULL
||
f_arg
!=
NULL
)
{
if
((
o
=
mgt_vcc_default
(
b_arg
,
vcl
,
C_flag
))
!=
0
)
exit
(
o
);
mgt_vcc_default
(
cli
,
b_arg
,
vcl
,
C_flag
);
if
(
C_flag
)
{
AZ
(
VSB_finish
(
cli
->
sb
));
fprintf
(
stderr
,
"%s
\n
"
,
VSB_data
(
cli
->
sb
));
exit
(
0
);
}
cli_check
(
cli
);
free
(
vcl
);
}
if
(
C_flag
)
exit
(
0
);
}
else
if
(
C_flag
)
ARGV_ERR
(
"-C only good with -b or -f
\n
"
);
if
(
!
d_flag
)
{
if
(
MGT_open_sockets
())
...
...
bin/varnishd/mgt/mgt_vcc.c
View file @
f9f26156
...
...
@@ -335,7 +335,7 @@ mgt_vcc_compile(struct vcc_priv *vp, struct vsb *sb, int C_flag)
/*--------------------------------------------------------------------*/
static
unsigne
d
static
voi
d
mgt_VccCompile
(
struct
cli
*
cli
,
const
char
*
vclname
,
const
char
*
vclsrc
,
int
C_flag
)
{
...
...
@@ -344,7 +344,7 @@ mgt_VccCompile(struct cli *cli, const char *vclname, const char *vclsrc,
unsigned
status
;
char
*
p
;
(
void
)
cli
;
AN
(
cli
)
;
sb
=
VSB_new_auto
();
XXXAN
(
sb
);
...
...
@@ -366,12 +366,8 @@ mgt_VccCompile(struct cli *cli, const char *vclname, const char *vclsrc,
status
=
mgt_vcc_compile
(
&
vp
,
sb
,
C_flag
);
AZ
(
VSB_finish
(
sb
));
if
(
VSB_len
(
sb
)
>
0
)
{
if
(
cli
!=
NULL
)
VCLI_Out
(
cli
,
"%s"
,
VSB_data
(
sb
));
else
fprintf
(
stderr
,
"%s"
,
VSB_data
(
sb
));
}
if
(
VSB_len
(
sb
)
>
0
)
VCLI_Out
(
cli
,
"%s"
,
VSB_data
(
sb
));
VSB_delete
(
sb
);
(
void
)
unlink
(
vp
.
srcfile
);
...
...
@@ -380,63 +376,55 @@ mgt_VccCompile(struct cli *cli, const char *vclname, const char *vclsrc,
if
(
status
||
C_flag
)
{
(
void
)
unlink
(
vp
.
libfile
);
free
(
vp
.
libfile
);
if
(
cli
!=
NULL
)
{
if
(
!
C_flag
)
{
VCLI_Out
(
cli
,
"VCL compilation failed"
);
}
else
if
(
!
C_flag
)
fprintf
(
stderr
,
"
\n
VCL compilation failed
\n
"
);
return
(
status
)
;
VCLI_SetResult
(
cli
,
CLIS_PARAM
);
}
return
;
}
if
(
cli
!=
NULL
)
VCLI_Out
(
cli
,
"VCL compiled.
\n
"
);
VCLI_Out
(
cli
,
"VCL compiled.
\n
"
);
if
(
c
li
==
NULL
||
c
hild_pid
<
0
)
{
if
(
child_pid
<
0
)
{
mgt_vcc_add
(
vclname
,
vp
.
libfile
);
free
(
vp
.
libfile
);
return
(
0
)
;
return
;
}
if
(
!
mgt_cli_askchild
(
&
status
,
&
p
,
"vcl.load %s %s
\n
"
,
vclname
,
vp
.
libfile
))
{
mgt_vcc_add
(
vclname
,
vp
.
libfile
);
free
(
vp
.
libfile
);
return
(
0
)
;
return
;
}
VCLI_SetResult
(
cli
,
status
);
VCLI_Out
(
cli
,
"%s"
,
p
);
VCLI_SetResult
(
cli
,
CLIS_PARAM
);
(
void
)
unlink
(
vp
.
libfile
);
free
(
vp
.
libfile
);
return
(
status
);
}
/*--------------------------------------------------------------------*/
unsigned
mgt_vcc_default
(
const
char
*
b_arg
,
const
char
*
vcl
,
int
C_flag
)
void
mgt_vcc_default
(
struct
cli
*
cli
,
const
char
*
b_arg
,
const
char
*
vclsrc
,
int
C_flag
)
{
char
buf
[
BUFSIZ
];
if
(
b_arg
==
NULL
)
{
AN
(
vcl
);
return
(
mgt_VccCompile
(
NULL
,
"boot"
,
vcl
,
C_flag
));
AN
(
vclsrc
);
mgt_VccCompile
(
cli
,
"boot"
,
vclsrc
,
C_flag
);
return
;
}
AZ
(
vcl
);
/*
* XXX: should do a "HEAD /" on the -b argument to see that
* XXX: it even works. On the other hand, we should do that
* XXX: for all backends in the cache process whenever we
* XXX: change config, but for a complex VCL, it might not be
* XXX: a bug for a backend to not reply at that time, so then
* XXX: again: we should check it here in the "trivial" case.
*/
AZ
(
vclsrc
);
bprintf
(
buf
,
"vcl 4.0;
\n
"
"backend default {
\n
"
" .host =
\"
%s
\"
;
\n
"
"}
\n
"
,
b_arg
);
return
(
mgt_VccCompile
(
NULL
,
"boot"
,
buf
,
C_flag
)
);
mgt_VccCompile
(
cli
,
"boot"
,
buf
,
C_flag
);
}
/*--------------------------------------------------------------------*/
...
...
@@ -509,8 +497,7 @@ mcf_vcl_inline(struct cli *cli, const char * const *av, void *priv)
return
;
}
if
(
mgt_VccCompile
(
cli
,
av
[
2
],
av
[
3
],
0
))
VCLI_SetResult
(
cli
,
CLIS_PARAM
);
mgt_VccCompile
(
cli
,
av
[
2
],
av
[
3
],
0
);
}
void
...
...
@@ -534,8 +521,7 @@ mcf_vcl_load(struct cli *cli, const char * const *av, void *priv)
return
;
}
if
(
mgt_VccCompile
(
cli
,
av
[
2
],
vcl
,
0
))
VCLI_SetResult
(
cli
,
CLIS_PARAM
);
mgt_VccCompile
(
cli
,
av
[
2
],
vcl
,
0
);
free
(
vcl
);
}
...
...
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