]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tools: Move handling of CTDB_SOCKET to process_command()
authorMartin Schwenke <martin@meltin.net>
Wed, 21 Feb 2018 10:31:01 +0000 (21:31 +1100)
committerAmitay Isaacs <amitay@samba.org>
Mon, 19 Mar 2018 01:23:18 +0000 (02:23 +0100)
options.socket will go away in future.  This moves processing of
CTDB_SOCKET close to where it is used.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tools/ctdb.c

index a2e8ef20b620c7b398c2de059fd77ee94261f1a8..d76d17612102262b2ec8282888119942a31a3de9 100644 (file)
@@ -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) {