From b595712f254d249e02cf4bbbc933063725286f78 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 21 Oct 2013 19:36:36 +1100 Subject: [PATCH] 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 Pair-programmed-with: Amitay Isaacs (This used to be ctdb commit 1fe82f3d7b610547ff4945887f15dd6c5798a49b) --- ctdb/include/ctdb_client.h | 7 ------- ctdb/server/ctdb_server.c | 36 ------------------------------------ ctdb/server/ctdbd.c | 24 +++--------------------- 3 files changed, 3 insertions(+), 64 deletions(-) diff --git a/ctdb/include/ctdb_client.h b/ctdb/include/ctdb_client.h index c270783e6ad..53b082978ca 100644 --- a/ctdb/include/ctdb_client.h +++ b/ctdb/include/ctdb_client.h @@ -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 */ diff --git a/ctdb/server/ctdb_server.c b/ctdb/server/ctdb_server.c index 1c0fa4ca9e7..41cc8819a57 100644 --- a/ctdb/server/ctdb_server.c +++ b/ctdb/server/ctdb_server.c @@ -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 */ diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c index f9e83f8c3f8..7fe99ba3118 100644 --- a/ctdb/server/ctdbd.c +++ b/ctdb/server/ctdbd.c @@ -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) {