From 1f916ec32048cffa78681a8319c717bcbd776e91 Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 3 Mar 2009 09:33:27 +0000 Subject: [PATCH] Minor bit of cleanup: initialize CLI from main() instead of mgt_run(). git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3861 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/mgt.h | 7 ++++--- varnish-cache/bin/varnishd/mgt_child.c | 15 +-------------- varnish-cache/bin/varnishd/varnishd.c | 23 +++++++++++++++++++---- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/varnish-cache/bin/varnishd/mgt.h b/varnish-cache/bin/varnishd/mgt.h index 245cc01f..a01a5d6a 100644 --- a/varnish-cache/bin/varnishd/mgt.h +++ b/varnish-cache/bin/varnishd/mgt.h @@ -37,11 +37,12 @@ struct cli; extern struct vev_base *mgt_evb; -extern unsigned d_flag; +extern unsigned d_flag; +extern pid_t mgt_pid; /* mgt_child.c */ -void mgt_run(const char *T_arg); -extern pid_t mgt_pid, child_pid; +extern pid_t child_pid; +void MGT_Run(void); void mgt_stop_child(void); /* mgt_cli.c */ diff --git a/varnish-cache/bin/varnishd/mgt_child.c b/varnish-cache/bin/varnishd/mgt_child.c index 019921d2..15ffc1dc 100644 --- a/varnish-cache/bin/varnishd/mgt_child.c +++ b/varnish-cache/bin/varnishd/mgt_child.c @@ -64,7 +64,6 @@ #include "vss.h" #include "vbm.h" -pid_t mgt_pid; pid_t child_pid = -1; static struct vbitmap *fd_map; @@ -89,7 +88,6 @@ static const char * const ch_state[] = { [CH_DIED] = "died, (restarting)", }; -struct vev_base *mgt_evb; static struct vev *ev_poker; static struct vev *ev_listen; static struct vlu *vlu; @@ -499,23 +497,12 @@ mgt_sigint(const struct vev *e, int what) */ void -mgt_run(const char *T_arg) +MGT_Run(void) { struct sigaction sac; struct vev *e; int i; - mgt_pid = getpid(); - - mgt_evb = vev_new_base(); - XXXAN(mgt_evb); - - if (d_flag) - mgt_cli_setup(0, 1, 1, "debug"); - - if (T_arg) - mgt_cli_telnet(T_arg); - e = vev_new(); XXXAN(e); e->sig = SIGTERM; diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index a0170611..52b3a570 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -58,6 +58,7 @@ #endif #include "vsb.h" +#include "vev.h" #include "vpf.h" #include "vsha256.h" @@ -76,9 +77,13 @@ #define INFTIM -1 #endif -struct heritage heritage; -volatile struct params *params; -unsigned d_flag = 0; +struct heritage heritage; +volatile struct params *params; +unsigned d_flag = 0; +pid_t mgt_pid; +struct vev_base *mgt_evb; + + /*--------------------------------------------------------------------*/ @@ -605,7 +610,17 @@ main(int argc, char * const *argv) if (pfh != NULL && vpf_write(pfh)) fprintf(stderr, "NOTE: Could not write PID file\n"); - mgt_run(T_arg); + mgt_pid = getpid(); + + mgt_evb = vev_new_base(); + XXXAN(mgt_evb); + + if (d_flag) + mgt_cli_setup(0, 1, 1, "debug"); + if (T_arg) + mgt_cli_telnet(T_arg); + + MGT_Run(); if (pfh != NULL) (void)vpf_remove(pfh); -- 2.39.5