#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"
#define SRVID_CTDB_PUSHDB (CTDB_SRVID_TOOL_RANGE | 0x0002000000000000LL)
static struct {
- const char *socket;
const char *debuglevelstr;
int timelimit;
int pnn;
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);
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);
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,
}
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");
setlinebuf(stdout);
/* Set default options */
- options.socket = CTDB_SOCKET;
options.debuglevelstr = NULL;
options.timelimit = 10;
options.sep = "|";