Simplify housekeeper shutdown
The two-part shutdown procedure for the housekeeper was not needed and caused problems if SIGINT wasn't raised. Since the main thread returns to the main function, a single shutdown function is all that the housekeeper needs to function. Moved all the shutdown related code into Housekeeper::stop to remove the waiting for the thread in the destructor.
This commit is contained in:
@ -45,17 +45,7 @@ typedef bool (*TASKFN)(void *data);
|
|||||||
bool hkinit();
|
bool hkinit();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shuts down the housekeeper mechanism.
|
* Waits for the housekeeper thread to finish.
|
||||||
*
|
|
||||||
* Should be called @b only if @c hkinit() returned successfully.
|
|
||||||
*
|
|
||||||
* @see hkinit hkfinish
|
|
||||||
*/
|
|
||||||
void hkshutdown();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Waits for the housekeeper thread to finish. Should be called only after
|
|
||||||
* hkshutdown() has been called.
|
|
||||||
*/
|
*/
|
||||||
void hkfinish();
|
void hkfinish();
|
||||||
|
|
||||||
|
|||||||
@ -2336,7 +2336,6 @@ int maxscale_shutdown()
|
|||||||
{
|
{
|
||||||
service_shutdown();
|
service_shutdown();
|
||||||
Worker::shutdown_all();
|
Worker::shutdown_all();
|
||||||
hkshutdown();
|
|
||||||
log_flush_shutdown();
|
log_flush_shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -92,7 +92,6 @@ class Housekeeper
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Housekeeper();
|
Housekeeper();
|
||||||
~Housekeeper();
|
|
||||||
|
|
||||||
static bool init();
|
static bool init();
|
||||||
void stop();
|
void stop();
|
||||||
@ -130,11 +129,6 @@ Housekeeper::Housekeeper():
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Housekeeper::~Housekeeper()
|
|
||||||
{
|
|
||||||
thread_wait(m_thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Housekeeper::init()
|
bool Housekeeper::init()
|
||||||
{
|
{
|
||||||
struct hkinit_result res;
|
struct hkinit_result res;
|
||||||
@ -190,6 +184,7 @@ void Housekeeper::run()
|
|||||||
void Housekeeper::stop()
|
void Housekeeper::stop()
|
||||||
{
|
{
|
||||||
atomic_store_uint32(&m_running, 0);
|
atomic_store_uint32(&m_running, 0);
|
||||||
|
thread_wait(m_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Housekeeper::add(const Task& task)
|
void Housekeeper::add(const Task& task)
|
||||||
@ -293,18 +288,16 @@ bool hkinit()
|
|||||||
return Housekeeper::init();
|
return Housekeeper::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hkshutdown()
|
|
||||||
{
|
|
||||||
ss_dassert(hk);
|
|
||||||
hk->stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void hkfinish()
|
void hkfinish()
|
||||||
{
|
{
|
||||||
|
if (hk)
|
||||||
|
{
|
||||||
MXS_NOTICE("Waiting for housekeeper to shut down.");
|
MXS_NOTICE("Waiting for housekeeper to shut down.");
|
||||||
|
hk->stop();
|
||||||
delete hk;
|
delete hk;
|
||||||
hk = NULL;
|
hk = NULL;
|
||||||
MXS_NOTICE("Housekeeper has shut down.");
|
MXS_NOTICE("Housekeeper has shut down.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hkshow_tasks(DCB *pDcb)
|
void hkshow_tasks(DCB *pDcb)
|
||||||
|
|||||||
Reference in New Issue
Block a user