diff options
author | unknown <anozdrin/alik@booka.> | 2006-11-21 17:31:03 +0300 |
---|---|---|
committer | unknown <anozdrin/alik@booka.> | 2006-11-21 17:31:03 +0300 |
commit | cbfff7304d60f56853bb1312dbe6fe42ebbeffee (patch) | |
tree | 6c79fe045d0eb04480800567a480ab43b9ad1d4f /server-tools/instance-manager/manager.cc | |
parent | 817c6a4f1a92ff2f38da695bf70e9ede0bd4d0a0 (diff) | |
download | mariadb-git-cbfff7304d60f56853bb1312dbe6fe42ebbeffee.tar.gz |
Polishing:
1) add support for joinable threads to Thread class;
2) move checking of thread model to Manager from mysqlmanager.cc,
because it is needed only for IM-main process.
server-tools/instance-manager/instance.cc:
Use Manager::is_linux_threads() instead of global variable.
server-tools/instance-manager/listener.cc:
Use Thread::start(DETACHED) instead of Thread::start_detached().
server-tools/instance-manager/manager.cc:
1. Use Thread::start(DETACHED) instead of Thread::start_detached();
2. Move checking of thread model to Manager from mysqlmanager.cc,
because it is needed only for IM-main process.
server-tools/instance-manager/manager.h:
Move checking of thread model to Manager from mysqlmanager.cc,
because it is needed only for IM-main process.
server-tools/instance-manager/mysqlmanager.cc:
Move checking of thread model to Manager from mysqlmanager.cc,
because it is needed only for IM-main process.
server-tools/instance-manager/priv.cc:
Move checking of thread model to Manager from mysqlmanager.cc,
because it is needed only for IM-main process.
server-tools/instance-manager/priv.h:
Move checking of thread model to Manager from mysqlmanager.cc,
because it is needed only for IM-main process.
server-tools/instance-manager/thread_registry.cc:
Add support of joinable threads to Thread class.
server-tools/instance-manager/thread_registry.h:
Add support of joinable threads to Thread class.
Diffstat (limited to 'server-tools/instance-manager/manager.cc')
-rw-r--r-- | server-tools/instance-manager/manager.cc | 80 |
1 files changed, 70 insertions, 10 deletions
diff --git a/server-tools/instance-manager/manager.cc b/server-tools/instance-manager/manager.cc index a55adbed950..faafcbee435 100644 --- a/server-tools/instance-manager/manager.cc +++ b/server-tools/instance-manager/manager.cc @@ -93,6 +93,65 @@ int my_sigwait(const sigset_t *set, int *sig) #endif +/********************************************************************** + Implementation of checking the actual thread model. +***********************************************************************/ + +namespace { /* no-indent */ + +class ThreadModelChecker: public Thread +{ +public: + ThreadModelChecker() + :main_pid(getpid()) + { } + +public: + inline bool is_linux_threads() const + { + return linux_threads; + } + +protected: + virtual void run() + { + linux_threads= main_pid != getpid(); + } + +private: + pid_t main_pid; + bool linux_threads; +}; + +bool check_if_linux_threads(bool *linux_threads) +{ + ThreadModelChecker checker; + + if (checker.start() || checker.join()) + return TRUE; + + *linux_threads= checker.is_linux_threads(); + + return FALSE; +} + +} + + +/********************************************************************** + Manager implementation +***********************************************************************/ + +Guardian *Manager::p_guardian; +Instance_map *Manager::p_instance_map; +Thread_registry *Manager::p_thread_registry; +User_map *Manager::p_user_map; + +#ifndef __WIN__ +bool Manager::linux_threads; +#endif // __WIN__ + + void Manager::stop_all_threads() { /* @@ -106,14 +165,6 @@ void Manager::stop_all_threads() p_thread_registry->deliver_shutdown(); } -/********************************************************************** - Manager implementation -***********************************************************************/ - -Guardian *Manager::p_guardian; -Instance_map *Manager::p_instance_map; -Thread_registry *Manager::p_thread_registry; -User_map *Manager::p_user_map; /* manager - entry point to the main instance manager process: start @@ -132,6 +183,15 @@ int Manager::main() bool shutdown_complete= FALSE; pid_t manager_pid= getpid(); + if (check_if_linux_threads(&linux_threads)) + { + log_error("Error: can not check if Linux Threads are used."); + return 1; + } + + log_info("Detected threads model: %s.", + (const char *) (linux_threads ? "LINUX threads" : "POSIX threads")); + Thread_registry thread_registry; /* All objects created in the manager() function live as long as @@ -228,7 +288,7 @@ int Manager::main() permitted to process instances. And before flush_instances() has completed, there are no instances to guard. */ - if (guardian.start_detached()) + if (guardian.start(Thread::DETACHED)) { log_error("Error: can not start Guardian thread."); goto err; @@ -255,7 +315,7 @@ int Manager::main() /* Initialize the Listener. */ - if (listener.start_detached()) + if (listener.start(Thread::DETACHED)) { log_error("Error: can not start Listener thread."); stop_all_threads(); |