diff options
Diffstat (limited to 'cli/src/cli.c')
| -rw-r--r-- | cli/src/cli.c | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/cli/src/cli.c b/cli/src/cli.c index 84ce0f46cb9..a52b39c5fb8 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -33,12 +33,6 @@ #include <malloc.h> #endif -#ifdef HAVE_MALLOC_STATS -#ifdef DEBUG -#include <mcheck.h> -#endif -#endif - #include "cli.h" #include "cli-quotad-client.h" #include "cli-cmd.h" @@ -61,7 +55,6 @@ #include "xdr-generic.h" -extern int connected; /* using argp for command line parsing */ const char *argp_program_version = @@ -78,12 +71,16 @@ const char *argp_program_version = const char *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">"; struct rpc_clnt *global_quotad_rpc; + struct rpc_clnt *global_rpc; rpc_clnt_prog_t *cli_rpc_prog; extern struct rpc_clnt_program cli_prog; +int cli_default_conn_timeout = 120; +int cli_ten_minutes_timeout = 600; + static int glusterfs_ctx_defaults_init(glusterfs_ctx_t *ctx) { @@ -122,8 +119,8 @@ glusterfs_ctx_defaults_init(glusterfs_ctx_t *ctx) goto out; } - ctx->event_pool = event_pool_new(DEFAULT_EVENT_POOL_SIZE, - STARTING_EVENT_THREADS); + ctx->event_pool = gf_event_pool_new(DEFAULT_EVENT_POOL_SIZE, + STARTING_EVENT_THREADS); if (!ctx->event_pool) { gf_log("cli", GF_LOG_ERROR, "Failed to create event pool."); goto out; @@ -223,7 +220,6 @@ logging_init(glusterfs_ctx_t *ctx, struct cli_state *state) /* passing ident as NULL means to use default ident for syslog */ if (gf_log_init(ctx, log_file, NULL) == -1) { fprintf(stderr, "ERROR: failed to open logfile %s\n", log_file); - return -1; } /* CLI should not have something to DEBUG after the release, @@ -307,14 +303,14 @@ cli_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, switch (event) { case RPC_CLNT_CONNECT: { - cli_cmd_broadcast_connected(); + cli_cmd_broadcast_connected(_gf_true); gf_log(this->name, GF_LOG_TRACE, "got RPC_CLNT_CONNECT"); break; } case RPC_CLNT_DISCONNECT: { + cli_cmd_broadcast_connected(_gf_false); gf_log(this->name, GF_LOG_TRACE, "got RPC_CLNT_DISCONNECT"); - connected = 0; if (!global_state->prompt && global_state->await_connected) { ret = 1; cli_out( @@ -377,8 +373,6 @@ cli_opt_parse(char *opt, struct cli_state *state) " bitrot commands\n" " volume quota help - display help for volume" " quota commands\n" - " volume tier help - display help for volume" - " tier commands\n" " snapshot help - display help for snapshot commands\n" " global help - list global commands\n"); exit(0); @@ -442,6 +436,12 @@ cli_opt_parse(char *opt, struct cli_state *state) return 0; } + oarg = strtail(opt, "inet6"); + if (oarg) { + state->address_family = "inet6"; + return 0; + } + oarg = strtail(opt, "log-file="); if (oarg) { state->log_file = oarg; @@ -664,9 +664,8 @@ cli_quotad_clnt_rpc_init(void) global_quotad_rpc = rpc; out: - if (ret) { - if (rpc_opts) - dict_unref(rpc_opts); + if (rpc_opts) { + dict_unref(rpc_opts); } return rpc; } @@ -688,6 +687,15 @@ cli_rpc_init(struct cli_state *state) this = THIS; cli_rpc_prog = &cli_prog; + options = dict_new(); + if (!options) + goto out; + + /* If address family specified in CLI */ + if (state->address_family) { + addr_family = state->address_family; + } + /* Connect to glusterd using the specified method, giving preference * to a unix socket connection. If nothing is specified, connect to * the default glusterd socket. @@ -697,7 +705,7 @@ cli_rpc_init(struct cli_state *state) "Connecting to glusterd using " "sockfile %s", state->glusterd_sock); - ret = rpc_transport_unix_options_build(&options, state->glusterd_sock, + ret = rpc_transport_unix_options_build(options, state->glusterd_sock, 0); if (ret) goto out; @@ -707,10 +715,6 @@ cli_rpc_init(struct cli_state *state) "%s", state->remote_host); - options = dict_new(); - if (!options) - goto out; - ret = dict_set_str(options, "remote-host", state->remote_host); if (ret) goto out; @@ -729,7 +733,7 @@ cli_rpc_init(struct cli_state *state) gf_log("cli", GF_LOG_DEBUG, "Connecting to glusterd using " "default socket"); - ret = rpc_transport_unix_options_build(&options, + ret = rpc_transport_unix_options_build(options, DEFAULT_GLUSTERD_SOCKFILE, 0); if (ret) goto out; @@ -747,6 +751,9 @@ cli_rpc_init(struct cli_state *state) ret = rpc_clnt_start(rpc); out: + if (options) + dict_unref(options); + if (ret) { if (rpc) rpc_clnt_unref(rpc); @@ -791,8 +798,7 @@ main(int argc, char *argv[]) int ret = -1; glusterfs_ctx_t *ctx = NULL; - mem_pools_init_early(); - mem_pools_init_late(); + mem_pools_init(); ctx = glusterfs_ctx_new(); if (!ctx) @@ -845,15 +851,11 @@ main(int argc, char *argv[]) if (ret) goto out; - ret = cli_cmd_cond_init(); - if (ret) - goto out; - ret = cli_input_init(&state); if (ret) goto out; - ret = event_dispatch(ctx->event_pool); + ret = gf_event_dispatch(ctx->event_pool); out: // glusterfs_ctx_destroy (ctx); |
