[master] 97c3fe2 Various cleanup
Poul-Henning Kamp
phk at FreeBSD.org
Tue Feb 10 16:18:15 CET 2015
commit 97c3fe275390922635a0c71e78b04a17d3d37a2e
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Feb 10 13:57:30 2015 +0000
Various cleanup
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index c57ac27..56de674 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -118,7 +118,7 @@ void STV_Config_Transient(void);
/* mgt_vcc.c */
void mgt_vcc_init(void);
-unsigned mgt_vcc_default(const char *bflag, const char *f_arg, char *vcl, int Cflag);
+unsigned mgt_vcc_default(const char *bflag, char *vcl, int Cflag);
int mgt_push_vcls_and_start(unsigned *status, char **p);
int mgt_has_vcl(void);
extern char *mgt_cc_cmd;
diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c
index 8c16692..c52b3cf 100644
--- a/bin/varnishd/mgt/mgt_cli.c
+++ b/bin/varnishd/mgt/mgt_cli.c
@@ -94,11 +94,11 @@ static struct cli_proto cli_proto[] = {
{ CLI_SERVER_STATUS, "", mcf_server_status, NULL },
{ CLI_SERVER_START, "", mcf_server_startstop, NULL },
{ CLI_SERVER_STOP, "", mcf_server_startstop, cli_proto },
- { CLI_VCL_LOAD, "", mcf_config_load, NULL },
- { CLI_VCL_INLINE, "", mcf_config_inline, NULL },
- { CLI_VCL_USE, "", mcf_config_use, NULL },
- { CLI_VCL_DISCARD, "", mcf_config_discard, NULL },
- { CLI_VCL_LIST, "", mcf_config_list, NULL },
+ { CLI_VCL_LOAD, "", mcf_vcl_load, NULL },
+ { CLI_VCL_INLINE, "", mcf_vcl_inline, NULL },
+ { CLI_VCL_USE, "", mcf_vcl_use, NULL },
+ { CLI_VCL_DISCARD, "", mcf_vcl_discard, NULL },
+ { CLI_VCL_LIST, "", mcf_vcl_list, NULL },
{ CLI_PARAM_SHOW, "", mcf_param_show, NULL },
{ CLI_PARAM_SET, "", mcf_param_set, NULL },
{ CLI_PANIC_SHOW, "", mcf_panic_show, NULL },
diff --git a/bin/varnishd/mgt/mgt_cli.h b/bin/varnishd/mgt/mgt_cli.h
index 4d04535..0782bf6 100644
--- a/bin/varnishd/mgt/mgt_cli.h
+++ b/bin/varnishd/mgt/mgt_cli.h
@@ -39,11 +39,11 @@ cli_func_t mcf_param_show;
cli_func_t mcf_param_set;
/* mgt_vcc.c */
-cli_func_t mcf_config_load;
-cli_func_t mcf_config_inline;
-cli_func_t mcf_config_use;
-cli_func_t mcf_config_discard;
-cli_func_t mcf_config_list;
+cli_func_t mcf_vcl_load;
+cli_func_t mcf_vcl_inline;
+cli_func_t mcf_vcl_use;
+cli_func_t mcf_vcl_discard;
+cli_func_t mcf_vcl_list;
/* stevedore.c */
extern struct cli_proto cli_stv[];
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 1a46837..074e81c 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -656,7 +656,7 @@ main(int argc, char * const *argv)
P_arg, strerror(errno));
if (b_arg != NULL || f_arg != NULL)
- if ((o = mgt_vcc_default(b_arg, f_arg, vcl, C_flag)) != 0)
+ if ((o = mgt_vcc_default(b_arg, vcl, C_flag)) != 0)
exit(o);
if (C_flag)
diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c
index 62a03d5..d094688 100644
--- a/bin/varnishd/mgt/mgt_vcc.c
+++ b/bin/varnishd/mgt/mgt_vcc.c
@@ -135,47 +135,11 @@ mgt_vcc_delbyname(const char *name)
return (1);
}
-/*--------------------------------------------------------------------
- * Prepare the compiler command line
- */
-static struct vsb *
-mgt_make_cc_cmd(const struct vcc_priv *vp)
+int
+mgt_has_vcl(void)
{
- struct vsb *sb;
- int pct;
- char *p;
- CHECK_OBJ_NOTNULL(vp, VCC_PRIV_MAGIC);
- sb = VSB_new_auto();
- XXXAN(sb);
- for (p = mgt_cc_cmd, pct = 0; *p; ++p) {
- if (pct) {
- switch (*p) {
- case 's':
- VSB_cat(sb, vp->srcfile);
- break;
- case 'o':
- VSB_cat(sb, vp->libfile);
- break;
- case '%':
- VSB_putc(sb, '%');
- break;
- default:
- VSB_putc(sb, '%');
- VSB_putc(sb, *p);
- break;
- }
- pct = 0;
- } else if (*p == '%') {
- pct = 1;
- } else {
- VSB_putc(sb, *p);
- }
- }
- if (pct)
- VSB_putc(sb, '%');
- AZ(VSB_finish(sb));
- return (sb);
+ return (!VTAILQ_EMPTY(&vclhead));
}
/*--------------------------------------------------------------------
@@ -231,16 +195,46 @@ static void
run_cc(void *priv)
{
struct vcc_priv *vp;
- struct vsb *cmdsb;
+ struct vsb *sb;
+ int pct;
+ char *p;
mgt_sandbox(SANDBOX_CC);
CAST_OBJ_NOTNULL(vp, priv, VCC_PRIV_MAGIC);
- /* Build the C-compiler command line */
- cmdsb = mgt_make_cc_cmd(vp);
+ sb = VSB_new_auto();
+ AN(sb);
+ for (p = mgt_cc_cmd, pct = 0; *p; ++p) {
+ if (pct) {
+ switch (*p) {
+ case 's':
+ VSB_cat(sb, vp->srcfile);
+ break;
+ case 'o':
+ VSB_cat(sb, vp->libfile);
+ break;
+ case '%':
+ VSB_putc(sb, '%');
+ break;
+ default:
+ VSB_putc(sb, '%');
+ VSB_putc(sb, *p);
+ break;
+ }
+ pct = 0;
+ } else if (*p == '%') {
+ pct = 1;
+ } else {
+ VSB_putc(sb, *p);
+ }
+ }
+ if (pct)
+ VSB_putc(sb, '%');
+ AZ(VSB_finish(sb));
(void)umask(0177);
- (void)execl("/bin/sh", "/bin/sh", "-c", VSB_data(cmdsb), (char*)0);
+ (void)execl("/bin/sh", "/bin/sh", "-c", VSB_data(sb), (char*)0);
+ VSB_delete(sb); // For flexelint
}
/*--------------------------------------------------------------------
@@ -385,7 +379,7 @@ mgt_VccCompile(struct vsb **sb, const char *vclname, const char *vclsrc,
/*--------------------------------------------------------------------*/
unsigned
-mgt_vcc_default(const char *b_arg, const char *f_arg, char *vcl, int C_flag)
+mgt_vcc_default(const char *b_arg, char *vcl, int C_flag)
{
char *vf;
struct vsb *sb;
@@ -393,9 +387,6 @@ mgt_vcc_default(const char *b_arg, const char *f_arg, char *vcl, int C_flag)
char buf[BUFSIZ];
unsigned status = 0;
- /* XXX: annotate vcl with -b/-f arg so people know where it came from */
- (void)f_arg;
-
if (b_arg != NULL) {
AZ(vcl);
/*
@@ -436,15 +427,6 @@ mgt_vcc_default(const char *b_arg, const char *f_arg, char *vcl, int C_flag)
/*--------------------------------------------------------------------*/
int
-mgt_has_vcl(void)
-{
-
- return (!VTAILQ_EMPTY(&vclhead));
-}
-
-/*--------------------------------------------------------------------*/
-
-int
mgt_push_vcls_and_start(unsigned *status, char **p)
{
struct vclprog *vp;
@@ -470,8 +452,7 @@ mgt_push_vcls_and_start(unsigned *status, char **p)
/*--------------------------------------------------------------------*/
-static
-void
+static void
mgt_vcc_atexit(void)
{
struct vclprog *vp;
@@ -500,7 +481,7 @@ mgt_vcc_init(void)
/*--------------------------------------------------------------------*/
void
-mcf_config_inline(struct cli *cli, const char * const *av, void *priv)
+mcf_vcl_inline(struct cli *cli, const char * const *av, void *priv)
{
char *vf, *p = NULL;
struct vsb *sb;
@@ -538,7 +519,7 @@ mcf_config_inline(struct cli *cli, const char * const *av, void *priv)
}
void
-mcf_config_load(struct cli *cli, const char * const *av, void *priv)
+mcf_vcl_load(struct cli *cli, const char * const *av, void *priv)
{
char *vf, *vcl;
struct vsb *sb;
@@ -598,7 +579,7 @@ mcf_find_vcl(struct cli *cli, const char *name)
}
void
-mcf_config_use(struct cli *cli, const char * const *av, void *priv)
+mcf_vcl_use(struct cli *cli, const char * const *av, void *priv)
{
unsigned status;
char *p = NULL;
@@ -628,7 +609,7 @@ mcf_config_use(struct cli *cli, const char * const *av, void *priv)
}
void
-mcf_config_discard(struct cli *cli, const char * const *av, void *priv)
+mcf_vcl_discard(struct cli *cli, const char * const *av, void *priv)
{
unsigned status;
char *p = NULL;
@@ -653,7 +634,7 @@ mcf_config_discard(struct cli *cli, const char * const *av, void *priv)
}
void
-mcf_config_list(struct cli *cli, const char * const *av, void *priv)
+mcf_vcl_list(struct cli *cli, const char * const *av, void *priv)
{
unsigned status;
char *p;
More information about the varnish-commit
mailing list