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:
Markus Mäkelä 2018-04-26 23:37:57 +03:00
parent df1fc49ac3
commit 59165b8dd5
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
3 changed files with 10 additions and 28 deletions

View File

@ -45,17 +45,7 @@ typedef bool (*TASKFN)(void *data);
bool hkinit();
/**
* Shuts down the housekeeper mechanism.
*
* 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.
* Waits for the housekeeper thread to finish.
*/
void hkfinish();

View File

@ -2336,7 +2336,6 @@ int maxscale_shutdown()
{
service_shutdown();
Worker::shutdown_all();
hkshutdown();
log_flush_shutdown();
}

View File

@ -92,7 +92,6 @@ class Housekeeper
{
public:
Housekeeper();
~Housekeeper();
static bool init();
void stop();
@ -130,11 +129,6 @@ Housekeeper::Housekeeper():
{
}
Housekeeper::~Housekeeper()
{
thread_wait(m_thread);
}
bool Housekeeper::init()
{
struct hkinit_result res;
@ -190,6 +184,7 @@ void Housekeeper::run()
void Housekeeper::stop()
{
atomic_store_uint32(&m_running, 0);
thread_wait(m_thread);
}
void Housekeeper::add(const Task& task)
@ -293,18 +288,16 @@ bool hkinit()
return Housekeeper::init();
}
void hkshutdown()
{
ss_dassert(hk);
hk->stop();
}
void hkfinish()
{
MXS_NOTICE("Waiting for housekeeper to shut down.");
delete hk;
hk = NULL;
MXS_NOTICE("Housekeeper has shut down.");
if (hk)
{
MXS_NOTICE("Waiting for housekeeper to shut down.");
hk->stop();
delete hk;
hk = NULL;
MXS_NOTICE("Housekeeper has shut down.");
}
}
void hkshow_tasks(DCB *pDcb)