Commit 8e558f2e authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Now that we keep track of loaded VCLs in the manager, we might

as well allow their manipulation also when the child is not
running.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@639 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent dbfb9d8b
......@@ -8,7 +8,7 @@
void mgt_run(int dflag);
void mgt_start_child(void);
void mgt_stop_child(void);
extern pid_t mgt_pid;
extern pid_t mgt_pid, child_pid;
/* mgt_cli.c */
......
......@@ -25,8 +25,8 @@
#include "mgt_cli.h"
pid_t mgt_pid;
pid_t child_pid = -1;
static pid_t child_pid = -1;
static int child_fds[2];
static unsigned child_should_run;
static pthread_t child_listen_thread;
......
......@@ -113,6 +113,7 @@ static struct cli_proto mgt_cli_proto[] = {
{ CLI_CONFIG_INLINE, mcf_config_inline, NULL },
{ CLI_CONFIG_USE, mcf_config_use, NULL },
{ CLI_CONFIG_DISCARD, mcf_config_discard, NULL },
{ CLI_CONFIG_LIST, mcf_config_list, NULL },
#if 0
{ CLI_SERVER_STOP, m_cli_func_server_stop, NULL },
{ CLI_SERVER_RESTART },
......
......@@ -10,3 +10,4 @@ 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;
......@@ -246,7 +246,8 @@ mcf_config_inline(struct cli *cli, char **av, void *priv)
return;
}
sbuf_delete(sb);
if (mgt_cli_askchild(&status, &p, "config.load %s %s\n", av[2], vf)) {
if (child_pid >= 0 &&
mgt_cli_askchild(&status, &p, "config.load %s %s\n", av[2], vf)) {
cli_result(cli, status);
cli_out(cli, "%s", p);
free(p);
......@@ -276,7 +277,8 @@ mcf_config_load(struct cli *cli, char **av, void *priv)
return;
}
sbuf_delete(sb);
if (mgt_cli_askchild(&status, &p, "config.load %s %s\n", av[2], vf)) {
if (child_pid >= 0 &&
mgt_cli_askchild(&status, &p, "config.load %s %s\n", av[2], vf)) {
cli_result(cli, status);
cli_out(cli, "%s", p);
free(p);
......@@ -334,6 +336,7 @@ mcf_config_discard(struct cli *cli, char **av, void *priv)
int status;
char *p;
struct vcls *vp;
(void)priv;
AZ(pthread_mutex_lock(&vcc_mtx));
vp = mcf_find_vcl(cli, av[2]);
......@@ -352,3 +355,29 @@ mcf_config_discard(struct cli *cli, char **av, void *priv)
}
AZ(pthread_mutex_unlock(&vcc_mtx));
}
void
mcf_config_list(struct cli *cli, char **av, void *priv)
{
int status;
char *p;
struct vcls *vp;
(void)av;
(void)priv;
if (child_pid >= 0) {
mgt_cli_askchild(&status, &p, "config.list\n");
cli_result(cli, status);
cli_out(cli, "%s", p);
free(p);
} else {
AZ(pthread_mutex_lock(&vcc_mtx));
TAILQ_FOREACH(vp, &vclhead, list) {
cli_out(cli, "%s %6s %s\n",
vp->active ? "*" : " ",
"N/A", vp->name);
}
AZ(pthread_mutex_unlock(&vcc_mtx));
}
}
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