ctdb-common: Rename system utility files
[vlendec/samba-autobuild/.git] / ctdb / tools / ctdb.c
index d76d17612102262b2ec8282888119942a31a3de9..981293554b06c5018116c87ebac6a50f1044fc15 100644 (file)
@@ -41,6 +41,7 @@
 #include "protocol/protocol_api.h"
 #include "protocol/protocol_util.h"
 #include "common/system.h"
+#include "common/system_socket.h"
 #include "client/client.h"
 #include "client/client_sync.h"
 
@@ -50,7 +51,6 @@
 #define SRVID_CTDB_PUSHDB  (CTDB_SRVID_TOOL_RANGE | 0x0002000000000000LL)
 
 static struct {
-       const char *socket;
        const char *debuglevelstr;
        int timelimit;
        int pnn;
@@ -478,28 +478,16 @@ static struct ctdb_node_map *ctdb_read_nodes_file(TALLOC_CTX *mem_ctx,
 static struct ctdb_node_map *read_nodes_file(TALLOC_CTX *mem_ctx, uint32_t pnn)
 {
        struct ctdb_node_map *nodemap;
-       char *nodepath;
        const char *nodes_list = NULL;
 
-       if (pnn != CTDB_UNKNOWN_PNN) {
-               nodepath = talloc_asprintf(mem_ctx, "CTDB_NODES_%u", pnn);
-               if (nodepath != NULL) {
-                       nodes_list = getenv(nodepath);
-               }
-       }
-       if (nodes_list == NULL) {
-               nodes_list = getenv("CTDB_NODES");
+       const char *basedir = getenv("CTDB_BASE");
+       if (basedir == NULL) {
+               basedir = CTDB_ETCDIR;
        }
+       nodes_list = talloc_asprintf(mem_ctx, "%s/nodes", basedir);
        if (nodes_list == NULL) {
-               const char *basedir = getenv("CTDB_BASE");
-               if (basedir == NULL) {
-                       basedir = CTDB_ETCDIR;
-               }
-               nodes_list = talloc_asprintf(mem_ctx, "%s/nodes", basedir);
-               if (nodes_list == NULL) {
-                       fprintf(stderr, "Memory allocation error\n");
-                       return NULL;
-               }
+               fprintf(stderr, "Memory allocation error\n");
+               return NULL;
        }
 
        nodemap = ctdb_read_nodes_file(mem_ctx, nodes_list);
@@ -3038,7 +3026,8 @@ static int control_tickle(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
 
        if (argc == 0) {
                struct ctdb_connection_list *clist;
-               int i, num_failed;
+               int i;
+               unsigned int num_failed;
 
                /* Client first but the src/dst logic is confused */
                ret = ctdb_connection_list_read(mem_ctx, false, &clist);
@@ -6097,8 +6086,6 @@ static void usage(const char *command)
 
 struct poptOption cmdline_options[] = {
        POPT_AUTOHELP
-       { "socket", 's', POPT_ARG_STRING, &options.socket, 0,
-               "CTDB socket path", "filename" },
        { "debug", 'd', POPT_ARG_STRING, &options.debuglevelstr, 0,
                "debug level"},
        { "timelimit", 't', POPT_ARG_INT, &options.timelimit, 0,
@@ -6160,14 +6147,14 @@ static int process_command(const struct ctdb_cmd *cmd, int argc,
        }
 
        ctdb_socket = getenv("CTDB_SOCKET");
-       if (ctdb_socket != NULL) {
-               options.socket = ctdb_socket;
+       if (ctdb_socket == NULL) {
+               ctdb_socket = CTDB_SOCKET;
        }
 
-       ret = ctdb_client_init(ctdb, ctdb->ev, options.socket, &ctdb->client);
+       ret = ctdb_client_init(ctdb, ctdb->ev, ctdb_socket, &ctdb->client);
        if (ret != 0) {
                fprintf(stderr, "Failed to connect to CTDB daemon (%s)\n",
-                       options.socket);
+                       ctdb_socket);
 
                if (!find_node_xpnn(ctdb, NULL)) {
                        fprintf(stderr, "Is this node part of CTDB cluster?\n");
@@ -6231,7 +6218,6 @@ int main(int argc, const char *argv[])
        setlinebuf(stdout);
 
        /* Set default options */
-       options.socket = CTDB_SOCKET;
        options.debuglevelstr = NULL;
        options.timelimit = 10;
        options.sep = "|";