From e310bbbe53d7b1db8c4b007d62a2b169fac51752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 4 Jan 2018 14:53:03 +0200 Subject: [PATCH] Initialize query classifier in housekeeper thread The query classifier was not initialized for the housekeeper thread. This means that tasks could not use the query classifier and as the avro conversion is done inside a task, it can't use it. --- server/core/housekeeper.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/server/core/housekeeper.c b/server/core/housekeeper.c index d7406d72f..2e68199b3 100644 --- a/server/core/housekeeper.c +++ b/server/core/housekeeper.c @@ -18,6 +18,7 @@ #include #include #include +#include /** * @file housekeeper.c Provide a mechanism to run periodic tasks @@ -57,21 +58,30 @@ static THREAD hk_thr_handle; static void hkthread(void *); +struct hkinit_result +{ + sem_t sem; + bool ok; +}; + bool hkinit() { - bool inited = false; + struct hkinit_result res; + sem_init(&res.sem, 0, 0); + res.ok = false; - if (thread_start(&hk_thr_handle, hkthread, NULL) != NULL) + if (thread_start(&hk_thr_handle, hkthread, &res) != NULL) { - inited = true; + sem_wait(&res.sem); } else { MXS_ALERT("Failed to start housekeeper thread."); } - return inited; + sem_destroy(&res.sem); + return res.ok; } /** @@ -262,6 +272,16 @@ hkthread(void *data) void *taskdata; int i; + struct hkinit_result* res = (struct hkinit_result*)data; + res->ok = qc_thread_init(QC_INIT_BOTH); + + if (!res->ok) + { + MXS_ERROR("Could not initialize housekeeper thread."); + } + + sem_post(&res->sem); + while (!do_shutdown) { for (i = 0; i < 10; i++) @@ -301,6 +321,7 @@ hkthread(void *data) spinlock_release(&tasklock); } + qc_thread_end(QC_INIT_BOTH); MXS_NOTICE("Housekeeper shutting down."); }