r639 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Fri Aug 4 13:10:57 CEST 2006
Author: phk
Date: 2006-08-04 13:10:57 +0200 (Fri, 04 Aug 2006)
New Revision: 639
Modified:
trunk/varnish-cache/bin/varnishd/mgt.h
trunk/varnish-cache/bin/varnishd/mgt_child.c
trunk/varnish-cache/bin/varnishd/mgt_cli.c
trunk/varnish-cache/bin/varnishd/mgt_cli.h
trunk/varnish-cache/bin/varnishd/mgt_vcc.c
Log:
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.
Modified: trunk/varnish-cache/bin/varnishd/mgt.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt.h 2006-08-04 10:54:30 UTC (rev 638)
+++ trunk/varnish-cache/bin/varnishd/mgt.h 2006-08-04 11:10:57 UTC (rev 639)
@@ -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 */
Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_child.c 2006-08-04 10:54:30 UTC (rev 638)
+++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2006-08-04 11:10:57 UTC (rev 639)
@@ -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;
Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2006-08-04 10:54:30 UTC (rev 638)
+++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2006-08-04 11:10:57 UTC (rev 639)
@@ -113,6 +113,7 @@
{ 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 },
Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_cli.h 2006-08-04 10:54:30 UTC (rev 638)
+++ trunk/varnish-cache/bin/varnishd/mgt_cli.h 2006-08-04 11:10:57 UTC (rev 639)
@@ -10,3 +10,4 @@
cli_func_t mcf_config_inline;
cli_func_t mcf_config_use;
cli_func_t mcf_config_discard;
+cli_func_t mcf_config_list;
Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2006-08-04 10:54:30 UTC (rev 638)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2006-08-04 11:10:57 UTC (rev 639)
@@ -246,7 +246,8 @@
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 @@
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 @@
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 @@
}
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));
+ }
+}
+
More information about the varnish-commit
mailing list