Commit 6df4d965 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Split mcf_server_startstop() into two separate functions

parent af2fb997
......@@ -611,17 +611,16 @@ mgt_stop_child(void)
}
/*=====================================================================
* CLI command to start/stop child
* CLI commands to start/stop child
*/
void __match_proto__(cli_func_t)
mcf_server_startstop(struct cli *cli, const char * const *av, void *priv)
mcf_server_start(struct cli *cli, const char * const *av, void *priv)
{
(void)av;
if (priv != NULL && child_state == CH_RUNNING)
mgt_stop_child();
else if (priv == NULL && child_state == CH_STOPPED) {
(void)priv;
if (child_state == CH_STOPPED) {
if (mgt_has_vcl()) {
mgt_launch_child(cli);
} else {
......@@ -634,6 +633,20 @@ mcf_server_startstop(struct cli *cli, const char * const *av, void *priv)
}
}
void __match_proto__(cli_func_t)
mcf_server_stop(struct cli *cli, const char * const *av, void *priv)
{
(void)av;
(void)priv;
if (child_state == CH_RUNNING) {
mgt_stop_child();
} else {
VCLI_SetResult(cli, CLIS_CANT);
VCLI_Out(cli, "Child in state %s", ch_state[child_state]);
}
}
/*--------------------------------------------------------------------*/
void
......
......@@ -89,20 +89,20 @@ mcf_banner(struct cli *cli, const char *const *av, void *priv)
/* XXX: what order should this list be in ? */
static struct cli_proto cli_proto[] = {
{ CLI_BANNER, "", mcf_banner, NULL },
{ 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_vcl_load, NULL },
{ CLI_VCL_INLINE, "", mcf_vcl_inline, NULL },
{ CLI_VCL_USE, "", mcf_vcl_use, NULL },
{ CLI_VCL_STATE, "", mcf_vcl_state, 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 },
{ CLI_PANIC_CLEAR, "", mcf_panic_clear, NULL },
{ CLI_BANNER, "", mcf_banner },
{ CLI_SERVER_STATUS, "", mcf_server_status },
{ CLI_SERVER_START, "", mcf_server_start },
{ CLI_SERVER_STOP, "", mcf_server_stop },
{ CLI_VCL_LOAD, "", mcf_vcl_load },
{ CLI_VCL_INLINE, "", mcf_vcl_inline },
{ CLI_VCL_USE, "", mcf_vcl_use },
{ CLI_VCL_STATE, "", mcf_vcl_state },
{ CLI_VCL_DISCARD, "", mcf_vcl_discard },
{ CLI_VCL_LIST, "", mcf_vcl_list },
{ CLI_PARAM_SHOW, "", mcf_param_show },
{ CLI_PARAM_SET, "", mcf_param_set },
{ CLI_PANIC_SHOW, "", mcf_panic_show },
{ CLI_PANIC_CLEAR, "", mcf_panic_clear },
{ NULL }
};
......
......@@ -29,7 +29,8 @@
*/
/* mgt_child.c */
cli_func_t mcf_server_startstop;
cli_func_t mcf_server_start;
cli_func_t mcf_server_stop;
cli_func_t mcf_server_status;
cli_func_t mcf_panic_show;
cli_func_t mcf_panic_clear;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment