From a7795fedd4ee2ed7de2dce89fd782ae20b03f6a4 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Mon, 26 Jul 2010 12:10:08 +0000 Subject: cli: Changes to provide proper exit status for gluster commandline Signed-off-by: Vijay Bellur Signed-off-by: Anand V. Avati BUG: 1205 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1205 --- cli/src/cli.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) (limited to 'cli/src/cli.c') diff --git a/cli/src/cli.c b/cli/src/cli.c index d70c67f85..5f734d8e8 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -74,6 +74,7 @@ #include +extern int connected; /* using argp for command line parsing */ static char gf_doc[] = ""; @@ -318,6 +319,41 @@ out: return ret; } +int +cli_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, + void *data) +{ + xlator_t *this = NULL; + int ret = 0; + + this = data; + + switch (event) { + case RPC_CLNT_CONNECT: + { + + cli_cmd_broadcast_connected (); + gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_CONNECT"); + break; + } + + case RPC_CLNT_DISCONNECT: + { + gf_log (this->name, GF_LOG_TRACE, "got RPC_CLNT_DISCONNECT"); + connected = 0; + break; + } + + default: + gf_log (this->name, GF_LOG_TRACE, + "got some other RPC event %d", event); + ret = 0; + break; + } + + return ret; +} + int parse_cmdline (int argc, char *argv[], struct cli_state *state) { @@ -393,8 +429,10 @@ cli_rpc_init (struct cli_state *state) dict_t *options = NULL; int ret = -1; int port = CLI_GLUSTERD_PORT; + xlator_t *this = NULL; + this = THIS; cli_rpc_prog = &cli3_1_prog; options = dict_new (); if (!options) @@ -418,8 +456,11 @@ cli_rpc_init (struct cli_state *state) if (ret) goto out; - rpc = rpc_clnt_init (&rpc_cfg, options, THIS->ctx, THIS->name); + rpc = rpc_clnt_init (&rpc_cfg, options, this->ctx, this->name); + if (rpc) { + ret = rpc_clnt_register_notify (rpc, cli_rpc_notify, this); + } out: return rpc; } @@ -459,6 +500,10 @@ main (int argc, char *argv[]) if (ret) goto out; + global_rpc = cli_rpc_init (&state); + if (!global_rpc) + goto out; + state.ctx = ctx; global_state = &state; @@ -474,9 +519,6 @@ main (int argc, char *argv[]) if (ret) goto out; - global_rpc = cli_rpc_init (&state); - if (!global_rpc) - goto out; ret = cli_input_init (&state); if (ret) -- cgit