summaryrefslogtreecommitdiffstats
path: root/ctdb/server
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2013-10-21 19:33:10 +1100
committerMartin Schwenke <martin@meltin.net>2013-10-22 15:37:54 +1100
commitf9ce563135ed036b48eb14a097e002c29aed97a7 (patch)
tree850962de11b99927525fd6c08aa9aeb0fb6726d6 /ctdb/server
parent27a63433698604888a1c58becefa120b50eb8e14 (diff)
downloadsamba-f9ce563135ed036b48eb14a097e002c29aed97a7.tar.gz
samba-f9ce563135ed036b48eb14a097e002c29aed97a7.tar.xz
samba-f9ce563135ed036b48eb14a097e002c29aed97a7.zip
ctdbd: Add nodes_file member to struct ctdb_context
This allows ctdb_load_nodes_file() to move to ctdb_server.c and ctdb_set_nlist() to become static. Setting ctdb->nodes_file needs to be done early, before the nodes file is loaded. It is now set from CTDB_BASE instead ETCDIR, so setting CTDB_BASE also needs to be done earlier. Unhack ctdbd_test.c - it no longer needs to define ctdb_load_nodes_file(). Signed-off-by: Martin Schwenke <martin@meltin.net> Pair-programmed-with: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit 20e705e63bd3b20837cc3ac92fdcf2a9650ccfc8)
Diffstat (limited to 'ctdb/server')
-rw-r--r--ctdb/server/ctdb_server.c12
-rw-r--r--ctdb/server/ctdbd.c29
2 files changed, 25 insertions, 16 deletions
diff --git a/ctdb/server/ctdb_server.c b/ctdb/server/ctdb_server.c
index d0c3461297..1c0fa4ca9e 100644
--- a/ctdb/server/ctdb_server.c
+++ b/ctdb/server/ctdb_server.c
@@ -197,7 +197,7 @@ static int ctdb_add_deleted_node(struct ctdb_context *ctdb)
/*
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;
@@ -265,6 +265,16 @@ int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist)
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
diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c
index 28fe879864..b04971760d 100644
--- a/ctdb/server/ctdbd.c
+++ b/ctdb/server/ctdbd.c
@@ -52,7 +52,7 @@ static struct {
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",
@@ -86,17 +86,6 @@ static void ctdb_recv_pkt(struct ctdb_context *ctdb, uint8_t *data, uint32_t len
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,
@@ -250,7 +239,20 @@ int main(int argc, const char *argv[])
*/
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) {
@@ -323,9 +325,6 @@ int main(int argc, const char *argv[])
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);
}