summaryrefslogtreecommitdiffstats
path: root/cli/src/cli.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-07-26 12:10:08 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-07-27 01:20:12 -0700
commita7795fedd4ee2ed7de2dce89fd782ae20b03f6a4 (patch)
tree60e173fcab4bbcf78060755b93dda83e2b707a42 /cli/src/cli.c
parentf803fae036177c3b9d9513f5b6300d426366eb62 (diff)
cli: Changes to provide proper exit status for gluster commandline
Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1205 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1205
Diffstat (limited to 'cli/src/cli.c')
-rw-r--r--cli/src/cli.c50
1 files changed, 46 insertions, 4 deletions
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 <fnmatch.h>
+extern int connected;
/* using argp for command line parsing */
static char gf_doc[] = "";
@@ -319,6 +320,41 @@ out:
}
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)
{
int ret = 0;
@@ -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)