summaryrefslogtreecommitdiff
path: root/server-tools/instance-manager/guardian.h
diff options
context:
space:
mode:
authorkostja@bodhi.local <>2006-11-17 16:11:04 +0300
committerkostja@bodhi.local <>2006-11-17 16:11:04 +0300
commit7278f45bfd303d0c6f0936fc0960f4496a2801cc (patch)
tree5ecdad467c796454f72a94e294ff4958563441fb /server-tools/instance-manager/guardian.h
parent2f69dfb28fdd3a98137ac16b7280bd86c9345d78 (diff)
downloadmariadb-git-7278f45bfd303d0c6f0936fc0960f4496a2801cc.tar.gz
Replace the approach using Foo_thread_args + Foo_thread and manually
spawned threads with a reusable class Thread. This is the second idea implemented in the Alik's patch for BUG#22306: STOP INSTANCE can not be applied for instances in Crashed, Failed and Abandoned. Commiting separately to ease review process.
Diffstat (limited to 'server-tools/instance-manager/guardian.h')
-rw-r--r--server-tools/instance-manager/guardian.h43
1 files changed, 14 insertions, 29 deletions
diff --git a/server-tools/instance-manager/guardian.h b/server-tools/instance-manager/guardian.h
index 4c518dddf23..0eee1dc631d 100644
--- a/server-tools/instance-manager/guardian.h
+++ b/server-tools/instance-manager/guardian.h
@@ -16,11 +16,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include <my_global.h>
-#include <my_sys.h>
-#include <my_list.h>
#include "thread_registry.h"
+#include <my_sys.h>
+#include <my_list.h>
#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
#pragma interface
@@ -31,30 +30,12 @@ class Instance_map;
class Thread_registry;
struct GUARD_NODE;
-pthread_handler_t guardian_thread_func(void *arg);
-
-struct Guardian_args
-{
- Thread_registry &thread_registry;
- Instance_map *instance_map;
- int monitoring_interval;
-
- Guardian_args(Thread_registry &thread_registry_arg,
- Instance_map *instance_map_arg,
- uint monitoring_interval_arg) :
- thread_registry(thread_registry_arg),
- instance_map(instance_map_arg),
- monitoring_interval(monitoring_interval_arg)
- {}
-};
-
-
-/*
+/**
The guardian thread is responsible for monitoring and restarting of guarded
instances.
*/
-class Guardian: public Guardian_args
+class Guardian: public Thread
{
public:
/* states of an instance */
@@ -82,12 +63,10 @@ public:
/* Return client state name. */
static const char *get_instance_state_name(enum_instance_state state);
- Guardian(Thread_registry &thread_registry_arg,
- Instance_map *instance_map_arg,
- uint monitoring_interval_arg);
- ~Guardian();
- /* Main funtion of the thread */
- void run();
+ Guardian(Thread_registry *thread_registry_arg,
+ Instance_map *instance_map_arg,
+ uint monitoring_interval_arg);
+ virtual ~Guardian();
/* Initialize or refresh the list of guarded instances */
int init();
/* Request guardian shutdown. Stop instances if needed */
@@ -117,6 +96,9 @@ public:
a valid list node.
*/
inline enum_instance_state get_instance_state(LIST *instance_node);
+protected:
+ /* Main funtion of the thread */
+ virtual void run();
public:
pthread_cond_t COND_guardian;
@@ -133,6 +115,9 @@ private:
private:
pthread_mutex_t LOCK_guardian;
Thread_info thread_info;
+ int monitoring_interval;
+ Thread_registry *thread_registry;
+ Instance_map *instance_map;
LIST *guarded_instances;
MEM_ROOT alloc;
/* this variable is set to TRUE when we want to stop Guardian thread */