diff options
author | anozdrin/alik@alik.opbmk <> | 2007-02-20 21:28:30 +0300 |
---|---|---|
committer | anozdrin/alik@alik.opbmk <> | 2007-02-20 21:28:30 +0300 |
commit | 61b624eb760bd3e3c8baf41c992000964b0840d5 (patch) | |
tree | 3b85b381282acd24583dc6851e2907783f8ae134 | |
parent | a91354c3be7cd5029a1442e8f413599dea84adbf (diff) | |
download | mariadb-git-61b624eb760bd3e3c8baf41c992000964b0840d5.tar.gz |
Polishing:
1. use MySQL headers instead of system ones;
2. move logical part of code into a separate function.
-rw-r--r-- | server-tools/instance-manager/angel.cc | 13 | ||||
-rw-r--r-- | server-tools/instance-manager/manager.cc | 78 | ||||
-rw-r--r-- | server-tools/instance-manager/manager.h | 1 | ||||
-rw-r--r-- | server-tools/instance-manager/mysqlmanager.cc | 6 |
4 files changed, 59 insertions, 39 deletions
diff --git a/server-tools/instance-manager/angel.cc b/server-tools/instance-manager/angel.cc index 37bbeaa8ce8..09d675b291d 100644 --- a/server-tools/instance-manager/angel.cc +++ b/server-tools/instance-manager/angel.cc @@ -17,19 +17,16 @@ #include "angel.h" -#include <signal.h> -#include <string.h> - -#include <sys/stat.h> -#include <sys/types.h> #include <sys/wait.h> - /* - Include my_global.h right after system includes so that we can change - system defines if needed. + sys/wait.h is needed for waitpid(). Unfortunately, there is no MySQL + include file, that can serve for this. Include it before MySQL system + headers so that we can change system defines if needed. */ #include "my_global.h" +#include "my_alarm.h" +#include "my_sys.h" /* Include other IM files. */ diff --git a/server-tools/instance-manager/manager.cc b/server-tools/instance-manager/manager.cc index 8c4c29d50cf..48dfa4c3571 100644 --- a/server-tools/instance-manager/manager.cc +++ b/server-tools/instance-manager/manager.cc @@ -185,6 +185,53 @@ void Manager::stop_all_threads() /** + Initialize user map and load password file. + + SYNOPSIS + init_user_map() + + RETURN + FALSE on success + TRUE on failure +*/ + +bool Manager::init_user_map(User_map *user_map) +{ + int err_code; + const char *err_msg; + + if (user_map->init()) + { + log_error("Manager: can not initialize user list: out of memory."); + return TRUE; + } + + err_code= user_map->load(Options::Main::password_file_name, &err_msg); + + if (!err_code) + return FALSE; + + if (err_code == ERR_PASSWORD_FILE_DOES_NOT_EXIST && + Options::Main::mysqld_safe_compatible) + { + /* + The password file does not exist, but we are running in + mysqld_safe-compatible mode. Continue, but complain in log. + */ + + log_info("Warning: password file does not exist, " + "nobody will be able to connect to Instance Manager."); + + return FALSE; + } + + log_error("Manager: %s.", (const char *) err_msg); + + return TRUE; +} + + +/** Main manager function. SYNOPSIS @@ -201,9 +248,7 @@ void Manager::stop_all_threads() int Manager::main() { - int err_code; int rc= 1; - const char *err_msg; bool shutdown_complete= FALSE; pid_t manager_pid= getpid(); @@ -258,33 +303,10 @@ int Manager::main() return 1; } - /* Initialize user map and load password file. */ - - if (user_map.init()) - { - log_error("Manager: can not initialize user list: out of memory."); - return 1; - } - - if ((err_code= user_map.load(Options::Main::password_file_name, &err_msg))) - { - if (err_code == ERR_PASSWORD_FILE_DOES_NOT_EXIST && - Options::Main::mysqld_safe_compatible) - { - /* - The password file does not exist, but we are running in - mysqld_safe-compatible mode. Continue, but complain in log. - */ + /* Initialize user db. */ - log_info("Warning: password file does not exist, " - "nobody will be able to connect to Instance Manager."); - } - else - { - log_error("Manager: %s.", (const char *) err_msg); - return 1; - } - } + if (init_user_map(&user_map)) + return 1; /* logging has been already done. */ /* Write Instance Manager pid file. */ diff --git a/server-tools/instance-manager/manager.h b/server-tools/instance-manager/manager.h index a884ec114de..e6956884603 100644 --- a/server-tools/instance-manager/manager.h +++ b/server-tools/instance-manager/manager.h @@ -51,6 +51,7 @@ public: private: static void stop_all_threads(); + static bool init_user_map(User_map *user_map); private: static Guardian *p_guardian; diff --git a/server-tools/instance-manager/mysqlmanager.cc b/server-tools/instance-manager/mysqlmanager.cc index f1382e067bb..75769af631a 100644 --- a/server-tools/instance-manager/mysqlmanager.cc +++ b/server-tools/instance-manager/mysqlmanager.cc @@ -62,7 +62,7 @@ mysql subsystem. */ -static int im_main(int argc, char *argv[]); +static int main_impl(int argc, char *argv[]); #ifndef __WIN__ static struct passwd *check_user(); @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) log_info("IM: started."); - return_value= im_main(argc, argv); + return_value= main_impl(argc, argv); log_info("IM: finished."); @@ -108,7 +108,7 @@ int main(int argc, char *argv[]) Instance Manager main functionality. *************************************************************************/ -int im_main(int argc, char *argv[]) +int main_impl(int argc, char *argv[]) { int rc; |