diff options
author | Martin Schwenke <martin@meltin.net> | 2013-10-21 19:33:10 +1100 |
---|---|---|
committer | Martin Schwenke <martin@meltin.net> | 2013-10-22 15:37:54 +1100 |
commit | f9ce563135ed036b48eb14a097e002c29aed97a7 (patch) | |
tree | 850962de11b99927525fd6c08aa9aeb0fb6726d6 /ctdb | |
parent | 27a63433698604888a1c58becefa120b50eb8e14 (diff) | |
download | samba-f9ce563135ed036b48eb14a097e002c29aed97a7.tar.gz |
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')
-rw-r--r-- | ctdb/include/ctdb_client.h | 6 | ||||
-rw-r--r-- | ctdb/include/ctdb_private.h | 1 | ||||
-rw-r--r-- | ctdb/server/ctdb_server.c | 12 | ||||
-rw-r--r-- | ctdb/server/ctdbd.c | 29 | ||||
-rw-r--r-- | ctdb/tests/src/ctdbd_test.c | 2 |
5 files changed, 26 insertions, 24 deletions
diff --git a/ctdb/include/ctdb_client.h b/ctdb/include/ctdb_client.h index ca2f7620e5b..c8c37da8e67 100644 --- a/ctdb/include/ctdb_client.h +++ b/ctdb/include/ctdb_client.h @@ -85,12 +85,6 @@ 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 */ diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 13e482f2334..967dd63c9a0 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -549,6 +549,7 @@ struct ctdb_context { struct ctdb_reloadips_handle *reload_ips; + const char *nodes_file; const char *public_addresses_file; struct trbt_tree *child_processes; diff --git a/ctdb/server/ctdb_server.c b/ctdb/server/ctdb_server.c index d0c34612973..1c0fa4ca9e7 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 28fe8798640..b04971760d4 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); } diff --git a/ctdb/tests/src/ctdbd_test.c b/ctdb/tests/src/ctdbd_test.c index bf95e0b84ff..fb29ba8f1b3 100644 --- a/ctdb/tests/src/ctdbd_test.c +++ b/ctdb/tests/src/ctdbd_test.c @@ -30,8 +30,6 @@ */ int script_log_level; bool fast_start; -void ctdb_load_nodes_file(struct ctdb_context *ctdb) {} - /* UTIL_OBJ */ #include "lib/util/idtree.c" |