From: phk Date: Fri, 13 Feb 2009 10:46:14 +0000 (+0000) Subject: Don't copy the debug flag around, make it a global instead. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4496f71b903a0a357b54dc755176d3420f64b2c7;p=varnish Don't copy the debug flag around, make it a global instead. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3765 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/mgt.h b/varnish-cache/bin/varnishd/mgt.h index cee8dd1b..1f601aaa 100644 --- a/varnish-cache/bin/varnishd/mgt.h +++ b/varnish-cache/bin/varnishd/mgt.h @@ -37,9 +37,10 @@ struct cli; extern struct vev_base *mgt_evb; +extern unsigned d_flag; /* mgt_child.c */ -void mgt_run(int dflag, const char *T_arg); +void mgt_run(const char *T_arg); extern pid_t mgt_pid, child_pid; void mgt_stop_child(void); @@ -49,7 +50,7 @@ void mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident); int mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...); void mgt_cli_start_child(int fdi, int fdo); void mgt_cli_stop_child(void); -void mgt_cli_telnet(int dflag, const char *T_arg); +void mgt_cli_telnet(const char *T_arg); /* mgt_param.c */ void MCF_ParamSync(void); diff --git a/varnish-cache/bin/varnishd/mgt_child.c b/varnish-cache/bin/varnishd/mgt_child.c index 12a8a187..019921d2 100644 --- a/varnish-cache/bin/varnishd/mgt_child.c +++ b/varnish-cache/bin/varnishd/mgt_child.c @@ -499,7 +499,7 @@ mgt_sigint(const struct vev *e, int what) */ void -mgt_run(int dflag, const char *T_arg) +mgt_run(const char *T_arg) { struct sigaction sac; struct vev *e; @@ -510,11 +510,11 @@ mgt_run(int dflag, const char *T_arg) mgt_evb = vev_new_base(); XXXAN(mgt_evb); - if (dflag) + if (d_flag) mgt_cli_setup(0, 1, 1, "debug"); if (T_arg) - mgt_cli_telnet(dflag, T_arg); + mgt_cli_telnet(T_arg); e = vev_new(); XXXAN(e); @@ -547,9 +547,9 @@ mgt_run(int dflag, const char *T_arg) AZ(sigaction(SIGPIPE, &sac, NULL)); AZ(sigaction(SIGHUP, &sac, NULL)); - if (!dflag && !mgt_has_vcl()) + if (!d_flag && !mgt_has_vcl()) REPORT0(LOG_ERR, "No VCL loaded yet"); - else if (!dflag) { + else if (!d_flag) { start_child(NULL); if (child_state == CH_STOPPED) exit(2); diff --git a/varnish-cache/bin/varnishd/mgt_cli.c b/varnish-cache/bin/varnishd/mgt_cli.c index 5f30145b..15a3ce0e 100644 --- a/varnish-cache/bin/varnishd/mgt_cli.c +++ b/varnish-cache/bin/varnishd/mgt_cli.c @@ -74,8 +74,6 @@ static VTAILQ_HEAD(,telnet) telnets = VTAILQ_HEAD_INITIALIZER(telnets); static void telnet_close_all(void); static void telnet_close_one(int fd); -static int dflag_copy; - /*--------------------------------------------------------------------*/ static void @@ -335,7 +333,7 @@ mgt_cli_close(struct cli_port *cp) (void)close(2); assert(open("/dev/null", O_WRONLY) == 2); - if (dflag_copy == 2) { + if (d_flag == 2) { mgt_stop_child(); telnet_close_all(); } @@ -475,15 +473,13 @@ telnet_accept(const struct vev *ev, int what) } void -mgt_cli_telnet(int dflag, const char *T_arg) +mgt_cli_telnet(const char *T_arg) { struct vss_addr **ta; char *addr, *port; int i, n, sock, good; struct telnet *tn; - dflag_copy = dflag; - XXXAZ(VSS_parse(T_arg, &addr, &port)); n = VSS_resolve(addr, port, &ta); if (n == 0) { diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index c3dd3314..8d241147 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -78,6 +78,7 @@ struct heritage heritage; volatile struct params *params; +unsigned d_flag = 0; /*--------------------------------------------------------------------*/ @@ -420,7 +421,6 @@ main(int argc, char * const *argv) { int o; unsigned C_flag = 0; - unsigned d_flag = 0; unsigned F_flag = 0; const char *b_arg = NULL; const char *f_arg = NULL; @@ -636,7 +636,7 @@ main(int argc, char * const *argv) if (pfh != NULL && vpf_write(pfh)) fprintf(stderr, "NOTE: Could not write PID file\n"); - mgt_run(d_flag, T_arg); + mgt_run(T_arg); if (pfh != NULL) (void)vpf_remove(pfh);