1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

ctdbd: Simplify database directory setting logic

No need to check if the options are set.  The options are always set
via static defaults.

No need to talloc_strdup() the values via wrapper functions.  The
options aren't going away.  Remove now unused ctdb_set_tdb_dir() and
similar functions.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 1fe82f3d7b610547ff4945887f15dd6c5798a49b)
This commit is contained in:
Martin Schwenke 2013-10-21 19:36:36 +11:00 committed by Amitay Isaacs
parent a604c3d945
commit b595712f25
3 changed files with 3 additions and 64 deletions

View File

@ -64,13 +64,6 @@ struct ctdb_context *ctdb_init(struct tevent_context *ev);
*/
int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
/*
set the directory for the local databases
*/
int ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir);
int ctdb_set_tdb_dir_persistent(struct ctdb_context *ctdb, const char *dir);
int ctdb_set_tdb_dir_state(struct ctdb_context *ctdb, const char *dir);
/*
set some flags
*/

View File

@ -77,42 +77,6 @@ int ctdb_set_recovery_lock_file(struct ctdb_context *ctdb, const char *file)
return 0;
}
/*
set the directory for the local databases
*/
int ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir)
{
ctdb->db_directory = talloc_strdup(ctdb, dir);
if (ctdb->db_directory == NULL) {
return -1;
}
return 0;
}
/*
set the directory for the persistent databases
*/
int ctdb_set_tdb_dir_persistent(struct ctdb_context *ctdb, const char *dir)
{
ctdb->db_directory_persistent = talloc_strdup(ctdb, dir);
if (ctdb->db_directory_persistent == NULL) {
return -1;
}
return 0;
}
/*
set the directory for internal state databases
*/
int ctdb_set_tdb_dir_state(struct ctdb_context *ctdb, const char *dir)
{
ctdb->db_directory_state = talloc_strdup(ctdb, dir);
if (ctdb->db_directory_state == NULL) {
return -1;
}
return 0;
}
/*
add a node to the list of nodes
*/

View File

@ -256,31 +256,13 @@ int main(int argc, const char *argv[])
}
ctdb_load_nodes_file(ctdb);
if (options.db_dir) {
ret = ctdb_set_tdb_dir(ctdb, options.db_dir);
if (ret == -1) {
DEBUG(DEBUG_ALERT,("ctdb_set_tdb_dir failed - %s\n", ctdb_errstr(ctdb)));
exit(1);
}
}
ctdb->db_directory = options.db_dir;
ctdb_mkdir_p_or_die(ctdb, ctdb->db_directory, 0700);
if (options.db_dir_persistent) {
ret = ctdb_set_tdb_dir_persistent(ctdb, options.db_dir_persistent);
if (ret == -1) {
DEBUG(DEBUG_ALERT,("ctdb_set_tdb_dir_persistent failed - %s\n", ctdb_errstr(ctdb)));
exit(1);
}
}
ctdb->db_directory_persistent = options.db_dir_persistent;
ctdb_mkdir_p_or_die(ctdb, ctdb->db_directory_persistent, 0700);
if (options.db_dir_state) {
ret = ctdb_set_tdb_dir_state(ctdb, options.db_dir_state);
if (ret == -1) {
DEBUG(DEBUG_ALERT,("ctdb_set_tdb_dir_state failed - %s\n", ctdb_errstr(ctdb)));
exit(1);
}
}
ctdb->db_directory_state = options.db_dir_state;
ctdb_mkdir_p_or_die(ctdb, ctdb->db_directory_state, 0700);
if (options.public_interface) {