diff --git a/include/maxscale/housekeeper.h b/include/maxscale/housekeeper.h index 432ad2c46..a2fec7073 100644 --- a/include/maxscale/housekeeper.h +++ b/include/maxscale/housekeeper.h @@ -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(); diff --git a/server/core/gateway.cc b/server/core/gateway.cc index 1fd56b78c..de8936e8c 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -2336,7 +2336,6 @@ int maxscale_shutdown() { service_shutdown(); Worker::shutdown_all(); - hkshutdown(); log_flush_shutdown(); } diff --git a/server/core/housekeeper.cc b/server/core/housekeeper.cc index 047dd2447..b6f576f71 100644 --- a/server/core/housekeeper.cc +++ b/server/core/housekeeper.cc @@ -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)