1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-02 09:41:40 +03:00

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.
This commit is contained in:
kostja@bodhi.local
2006-11-17 16:11:04 +03:00
parent 2f69dfb28f
commit 7278f45bfd
13 changed files with 337 additions and 421 deletions

View File

@@ -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 */