]> err.no Git - varnish/commitdiff
Now that we keep track of loaded VCLs in the manager, we might
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 4 Aug 2006 11:10:57 +0000 (11:10 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 4 Aug 2006 11:10:57 +0000 (11:10 +0000)
as well allow their manipulation also when the child is not
running.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@639 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/mgt.h
varnish-cache/bin/varnishd/mgt_child.c
varnish-cache/bin/varnishd/mgt_cli.c
varnish-cache/bin/varnishd/mgt_cli.h
varnish-cache/bin/varnishd/mgt_vcc.c

index 83373b30d29ed5d8bc3a4272539c1d1acc5e9e6c..5537c9d076a2eb572adf69c7147b4d5524381903 100644 (file)
@@ -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 */
 
index cfcc9a7315fb3a424cfce163dbcfbc8a4e32fa74..8284466b13890a82ff71595184006c8d5aeeb1b6 100644 (file)
@@ -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;
index 36c63f4736134576d8381e6312f8643a34a4cca3..8f6f1803468b60807901bc33cfa693a2bf210852 100644 (file)
@@ -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 },
index 5d05d78e0ad56b1cb6e3d6dd80f4b01f72446276..0c8f280ba4141bfaf3fc4c09f05ad3671e30d6cc 100644 (file)
@@ -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;
index 778b4c30f23784d6b4e19e7d60636b2a1b5584af..f53ed03bc48f83bb002642d3d75293efe83cd248 100644 (file)
@@ -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));
+       }
+}
+