ctdbd: Simplify database directory setting logic
authorMartin Schwenke <martin@meltin.net>
Mon, 21 Oct 2013 08:36:36 +0000 (19:36 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 25 Oct 2013 01:06:06 +0000 (12:06 +1100)
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)

ctdb/include/ctdb_client.h
ctdb/server/ctdb_server.c
ctdb/server/ctdbd.c

index c270783e6adbb7dff69033152bc60dd38fd1867b..53b082978ca0b64e963976391b7579dfd22ffd25 100644 (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
 */
index 1c0fa4ca9e719600f6957ddcedd78c09f5ec669c..41cc8819a57208847b325581dd5de688689e379a 100644 (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
 */
index f9e83f8c3f8d826a21306ef887b0df24ff36e14f..7fe99ba3118c2206cb82c3a39da7d9323bd331b8 100644 (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) {