From: Martin Schwenke Date: Wed, 21 Feb 2018 10:31:01 +0000 (+1100) Subject: ctdb-tools: Move handling of CTDB_SOCKET to process_command() X-Git-Tag: talloc-2.1.12~126 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0045a7cfeeb51e4283bf63bdc6a100e34b95e2a9;p=thirdparty%2Fsamba.git ctdb-tools: Move handling of CTDB_SOCKET to process_command() options.socket will go away in future. This moves processing of CTDB_SOCKET close to where it is used. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index a2e8ef20b62..d76d1761210 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -6123,6 +6123,7 @@ static int process_command(const struct ctdb_cmd *cmd, int argc, { TALLOC_CTX *tmp_ctx; struct ctdb_context *ctdb; + const char *ctdb_socket; int ret; bool status; uint64_t srvid_offset; @@ -6158,6 +6159,11 @@ static int process_command(const struct ctdb_cmd *cmd, int argc, goto fail; } + ctdb_socket = getenv("CTDB_SOCKET"); + if (ctdb_socket != NULL) { + options.socket = ctdb_socket; + } + ret = ctdb_client_init(ctdb, ctdb->ev, options.socket, &ctdb->client); if (ret != 0) { fprintf(stderr, "Failed to connect to CTDB daemon (%s)\n", @@ -6219,7 +6225,6 @@ int main(int argc, const char *argv[]) const char **extra_argv; int extra_argc; const struct ctdb_cmd *cmd; - const char *ctdb_socket; int loglevel; int ret; @@ -6233,11 +6238,6 @@ int main(int argc, const char *argv[]) options.maxruntime = 0; options.pnn = -1; - ctdb_socket = getenv("CTDB_SOCKET"); - if (ctdb_socket != NULL) { - options.socket = ctdb_socket; - } - pc = poptGetContext(argv[0], argc, argv, cmdline_options, POPT_CONTEXT_KEEP_FIRST); while ((opt = poptGetNextOpt(pc)) != -1) {