[master] 5eba657 Have the stevedore register its own cli commands and retire mgt_cli.h
Poul-Henning Kamp
phk at FreeBSD.org
Sun May 22 01:06:05 CEST 2016
commit 5eba65726f1e03d4f536b707200c52b4cf4f1504
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sat May 21 22:41:38 2016 +0000
Have the stevedore register its own cli commands and retire mgt_cli.h
diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am
index 792e7fa..1a328fb 100644
--- a/bin/varnishd/Makefile.am
+++ b/bin/varnishd/Makefile.am
@@ -113,7 +113,6 @@ noinst_HEADERS = \
hash/hash_slinger.h \
http1/cache_http1.h \
mgt/mgt.h \
- mgt/mgt_cli.h \
mgt/mgt_param.h \
storage/storage.h \
storage/storage_simple.h \
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index 7152530..20fd20d 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -69,6 +69,8 @@ void mgt_cli_secret(const char *S_arg);
void mgt_cli_close_all(void);
void mgt_DumpRstCli(void);
void mgt_cli_init_cls(void);
+#define MCF_NOAUTH 0 /* NB: zero disables here-documents */
+#define MCF_AUTH 16
/* mgt_jail.c */
diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c
index 0c6482f..d451e97 100644
--- a/bin/varnishd/mgt/mgt_child.c
+++ b/bin/varnishd/mgt/mgt_child.c
@@ -54,8 +54,6 @@
#include "vlu.h"
#include "vtim.h"
-#include "mgt_cli.h"
-
pid_t child_pid = -1;
static struct vbitmap *fd_map;
@@ -715,7 +713,7 @@ MGT_Run(void)
struct vev *e;
int i;
- VCLS_AddFunc(mgt_cls, 0, cli_child);
+ VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_child);
mgt_uptime_t0 = VTIM_real();
e = vev_new();
diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c
index 7e7a0af..e6ed6a5 100644
--- a/bin/varnishd/mgt/mgt_cli.c
+++ b/bin/varnishd/mgt/mgt_cli.c
@@ -55,8 +55,6 @@
#include "vss.h"
#include "vtcp.h"
-#include "mgt_cli.h"
-
#define CLI_CMD(U,l,s,h,d,m,M) \
const struct cli_cmd_desc CLICMD_##U[1] = {{ l, s, h, d, m, M }};
#include "tbl/cli_cmds.h"
@@ -74,9 +72,6 @@ static int cli_i = -1, cli_o = -1;
struct VCLS *mgt_cls;
static const char *secret_file;
-#define MCF_NOAUTH 0 /* NB: zero disables here-documents */
-#define MCF_AUTH 16
-
/*--------------------------------------------------------------------*/
static void
@@ -102,8 +97,6 @@ mcf_banner(struct cli *cli, const char *const *av, void *priv)
static struct cli_proto cli_proto[] = {
{ CLICMD_BANNER, "", mcf_banner },
- { CLICMD_PARAM_SHOW, "", mcf_param_show },
- { CLICMD_PARAM_SET, "", mcf_param_set },
{ NULL }
};
@@ -361,7 +354,6 @@ mgt_cli_init_cls(void)
VCLS_AddFunc(mgt_cls, MCF_NOAUTH, cli_auth);
VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_proto);
VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_debug);
- VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_stv);
VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_askchild);
}
diff --git a/bin/varnishd/mgt/mgt_cli.h b/bin/varnishd/mgt/mgt_cli.h
deleted file mode 100644
index 5d57817..0000000
--- a/bin/varnishd/mgt/mgt_cli.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2011 Varnish Software AS
- * All rights reserved.
- *
- * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-/* mgt_param.c */
-cli_func_t mcf_param_show;
-cli_func_t mcf_param_set;
-
-/* 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 42a0977..f5b41c9 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -560,6 +560,8 @@ main(int argc, char * const *argv)
clilim = 32768;
cli[0].limit = &clilim;
+ mgt_cli_init_cls(); // CLI commands can be registered
+
/* Various initializations */
VTAILQ_INIT(&heritage.socks);
mgt_evb = vev_new_base();
@@ -691,8 +693,6 @@ main(int argc, char * const *argv)
}
}
- mgt_cli_init_cls(); // CLI commands can be registered
-
if (!jailed)
VJ_Init(NULL);
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index 44c64d7..4211920 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -43,8 +43,7 @@
#include "vcli.h"
#include "vcli_common.h"
#include "vcli_priv.h"
-
-#include "mgt_cli.h"
+#include "vcli_serve.h"
struct plist {
unsigned magic;
@@ -230,7 +229,7 @@ mcf_wrap(struct cli *cli, const char *text)
/*--------------------------------------------------------------------*/
-void
+static void __match_proto__(cli_func_t)
mcf_param_show(struct cli *cli, const char * const *av, void *priv)
{
int n;
@@ -381,7 +380,7 @@ MCF_ParamSet(struct cli *cli, const char *param, const char *val)
/*--------------------------------------------------------------------*/
-void
+static void __match_proto__(cli_func_t)
mcf_param_set(struct cli *cli, const char * const *av, void *priv)
{
@@ -444,6 +443,14 @@ mcf_wash_param(struct cli *cli, const struct parspec *pp, const char **val,
}
}
+/*--------------------------------------------------------------------*/
+
+static struct cli_proto cli_params[] = {
+ { CLICMD_PARAM_SHOW, "", mcf_param_show },
+ { CLICMD_PARAM_SET, "", mcf_param_set },
+ { NULL }
+};
+
/*--------------------------------------------------------------------
* Wash the min/max/default values, and leave the default set.
*/
@@ -455,6 +462,8 @@ MCF_InitParams(struct cli *cli)
struct parspec *pp;
struct vsb *vsb;
+ VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_params);
+
vsb = VSB_new_auto();
AN(vsb);
VTAILQ_FOREACH(pl, &phead, list) {
diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index 770c551..67d8c40 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -46,8 +46,6 @@
#include "vev.h"
#include "vtim.h"
-#include "mgt_cli.h"
-
static const char * const VCL_STATE_COLD = "cold";
static const char * const VCL_STATE_WARM = "warm";
static const char * const VCL_STATE_AUTO = "auto";
@@ -496,5 +494,5 @@ mgt_vcl_init(void)
AZ(atexit(mgt_vcl_atexit));
- VCLS_AddFunc(mgt_cls, 0, cli_vcl);
+ VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_vcl);
}
diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c
index 644b899..a540136 100644
--- a/bin/varnishd/storage/mgt_stevedore.c
+++ b/bin/varnishd/storage/mgt_stevedore.c
@@ -40,7 +40,7 @@
#include "mgt/mgt.h"
#include "vcli_priv.h"
-#include "mgt/mgt_cli.h"
+#include "vcli_serve.h"
#include "storage/storage.h"
#include "vav.h"
@@ -52,7 +52,7 @@ struct stevedore *stv_transient;
/*--------------------------------------------------------------------*/
-static void
+static void __match_proto__(cli_func_t)
stv_cli_list(struct cli *cli, const char * const *av, void *priv)
{
struct stevedore *stv;
@@ -69,7 +69,7 @@ stv_cli_list(struct cli *cli, const char * const *av, void *priv)
/*--------------------------------------------------------------------*/
-struct cli_proto cli_stv[] = {
+static struct cli_proto cli_stv[] = {
{ CLICMD_STORAGE_LIST, "", stv_cli_list },
{ NULL}
};
@@ -199,8 +199,7 @@ STV_Config_Transient(void)
ASSERT_MGT();
+ VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_stv);
if (stv_transient == NULL)
STV_Config(TRANSIENT_STORAGE "=malloc");
}
-
-/*--------------------------------------------------------------------*/
More information about the varnish-commit
mailing list