summaryrefslogtreecommitdiff
path: root/server-tools/instance-manager/instance_map.cc
diff options
context:
space:
mode:
authorpetr@mysql.com <>2005-02-15 04:38:33 +0300
committerpetr@mysql.com <>2005-02-15 04:38:33 +0300
commit59d8e51150faa3aeaf489c4454fd6780ad849239 (patch)
tree11422217e66ff042bc75eb00563d6c7b1f36e26f /server-tools/instance-manager/instance_map.cc
parentbb8e5b6227ef83b67fd9a786bd32768231d42bdb (diff)
downloadmariadb-git-59d8e51150faa3aeaf489c4454fd6780ad849239.tar.gz
some more cleanups and fixes
Diffstat (limited to 'server-tools/instance-manager/instance_map.cc')
-rw-r--r--server-tools/instance-manager/instance_map.cc47
1 files changed, 34 insertions, 13 deletions
diff --git a/server-tools/instance-manager/instance_map.cc b/server-tools/instance-manager/instance_map.cc
index 5044bfb0f43..191677889e9 100644
--- a/server-tools/instance-manager/instance_map.cc
+++ b/server-tools/instance-manager/instance_map.cc
@@ -74,7 +74,7 @@ static void delete_instance(void *u)
1 - error occured
*/
-static int process_option(void * ctx, const char *group, const char *option)
+static int process_option(void *ctx, const char *group, const char *option)
{
Instance_map *map= NULL;
Instance *instance= NULL;
@@ -178,18 +178,41 @@ Instance_map::find(const char *name, uint name_len)
}
-void Instance_map::complete_initialization()
+int Instance_map::complete_initialization()
{
Instance *instance;
uint i= 0;
- while (i < hash.records)
+ if (hash.records == 0) /* no instances found */
{
- instance= (Instance *) hash_element(&hash, i);
- instance->complete_initialization(this);
- instance->options.complete_initialization(mysqld_path);
- i++;
+ if ((instance= new Instance) == 0)
+ goto err;
+
+ if (instance->init("mysqld") || add_instance(instance))
+ goto err_instance;
+
+ /*
+ After an instance have been added to the instance_map,
+ hash_free should handle it's deletion.
+ */
+ if (instance->complete_initialization(this, mysqld_path))
+ goto err;
}
+ else
+ while (i < hash.records)
+ {
+ instance= (Instance *) hash_element(&hash, i);
+ if (instance->complete_initialization(this, mysqld_path))
+ goto err;
+ i++;
+ }
+
+ return 0;
+err:
+ return 1;
+err_instance:
+ delete instance;
+ return 1;
}
@@ -197,13 +220,11 @@ void Instance_map::complete_initialization()
int Instance_map::load()
{
- int error;
-
- error= process_default_option_files("my", process_option, (void *) this);
-
- complete_initialization();
+ if (process_default_option_files("my", process_option, (void *) this) ||
+ complete_initialization())
+ return 1;
- return error;
+ return 0;
}