int ctdb_set_socketname(struct ctdb_context *ctdb, const char *socketname);
const char *ctdb_get_socketname(struct ctdb_context *ctdb);
-/*
- tell ctdb what nodes are available. This takes a filename, which will contain
- 1 node address per line, in a transport specific format
-*/
-int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist);
-
/*
Check that a specific ip address exists in the node list and returns
the id for the node or -1
/*
setup the node list from a file
*/
-int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist)
+static int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist)
{
char **lines;
int nlines;
return 0;
}
+void ctdb_load_nodes_file(struct ctdb_context *ctdb)
+{
+ int ret;
+
+ ret = ctdb_set_nlist(ctdb, ctdb->nodes_file);
+ if (ret == -1) {
+ DEBUG(DEBUG_ALERT,("ctdb_set_nlist failed - %s\n", ctdb_errstr(ctdb)));
+ exit(1);
+ }
+}
/*
setup the local node address
int no_publicipcheck;
int max_persistent_check_errors;
} options = {
- .nlist = ETCDIR "/ctdb/nodes",
+ .nlist = NULL,
.transport = "tcp",
.event_script_dir = ETCDIR "/ctdb/events.d",
.logfile = LOGDIR "/log.ctdb",
ctdb_input_pkt(ctdb, hdr);
}
-void ctdb_load_nodes_file(struct ctdb_context *ctdb)
-{
- int ret;
-
- ret = ctdb_set_nlist(ctdb, options.nlist);
- if (ret == -1) {
- DEBUG(DEBUG_ALERT,("ctdb_set_nlist failed - %s\n", ctdb_errstr(ctdb)));
- exit(1);
- }
-}
-
static const struct ctdb_upcalls ctdb_upcalls = {
.recv_pkt = ctdb_recv_pkt,
.node_dead = ctdb_node_dead,
*/
ctdb->pnn = -1;
+ /* Default value for CTDB_BASE - don't override */
+ setenv("CTDB_BASE", ETCDIR "/ctdb", 0);
+
/* tell ctdb what nodes are available */
+ if (options.nlist != NULL) {
+ ctdb->nodes_file = options.nlist;
+ } else {
+ ctdb->nodes_file =
+ talloc_asprintf(ctdb, "%s/nodes", getenv("CTDB_BASE"));
+ if (ctdb->nodes_file == NULL) {
+ DEBUG(DEBUG_ALERT,(__location__ " Out of memory\n"));
+ exit(1);
+ }
+ }
ctdb_load_nodes_file(ctdb);
if (options.db_dir) {
ctdb->max_persistent_check_errors = (uint64_t)options.max_persistent_check_errors;
}
- /* Default value for CTDB_BASE - don't override */
- setenv("CTDB_BASE", ETCDIR "/ctdb", 0);
-
/* start the protocol running (as a child) */
return ctdb_start_daemon(ctdb, interactive?false:true, options.use_syslog, options.public_address_list);
}