1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

ctdbd: Remove duplicate database directory setting logic

Defaults for ctdb->db_directory and similar variables are currently
set in 2 places.

Change this to set them in only 1 place and make the directories at
initialisation time instead of waiting until later.

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

(This used to be ctdb commit d73d84346488a2ed54e6a86f9d7ec641c8e33ace)
This commit is contained in:
Martin Schwenke 2013-10-21 19:36:36 +11:00 committed by Amitay Isaacs
parent bd73e017b0
commit a604c3d945
2 changed files with 5 additions and 34 deletions

View File

@ -1235,40 +1235,6 @@ int ctdb_attach_databases(struct ctdb_context *ctdb)
char *unhealthy_reason = NULL;
bool first_try = true;
if (ctdb->db_directory == NULL) {
ctdb->db_directory = VARDIR "/ctdb";
}
if (ctdb->db_directory_persistent == NULL) {
ctdb->db_directory_persistent = VARDIR "/ctdb/persistent";
}
if (ctdb->db_directory_state == NULL) {
ctdb->db_directory_state = VARDIR "/ctdb/state";
}
/* make sure the db directory exists */
ret = mkdir(ctdb->db_directory, 0700);
if (ret == -1 && errno != EEXIST) {
DEBUG(DEBUG_CRIT,(__location__ " Unable to create ctdb directory '%s'\n",
ctdb->db_directory));
return -1;
}
/* make sure the persistent db directory exists */
ret = mkdir(ctdb->db_directory_persistent, 0700);
if (ret == -1 && errno != EEXIST) {
DEBUG(DEBUG_CRIT,(__location__ " Unable to create ctdb persistent directory '%s'\n",
ctdb->db_directory_persistent));
return -1;
}
/* make sure the internal state db directory exists */
ret = mkdir(ctdb->db_directory_state, 0700);
if (ret == -1 && errno != EEXIST) {
DEBUG(DEBUG_CRIT,(__location__ " Unable to create ctdb state directory '%s'\n",
ctdb->db_directory_state));
return -1;
}
persistent_health_path = talloc_asprintf(ctdb, "%s/%s.%u",
ctdb->db_directory_state,
PERSISTENT_HEALTH_TDB,

View File

@ -263,6 +263,8 @@ int main(int argc, const char *argv[])
exit(1);
}
}
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) {
@ -270,6 +272,8 @@ int main(int argc, const char *argv[])
exit(1);
}
}
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) {
@ -277,6 +281,7 @@ int main(int argc, const char *argv[])
exit(1);
}
}
ctdb_mkdir_p_or_die(ctdb, ctdb->db_directory_state, 0700);
if (options.public_interface) {
ctdb->default_public_interface = talloc_strdup(ctdb, options.public_interface);