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.
This commit is contained in:
parent
a732a4c9a2
commit
e310bbbe53
@ -18,6 +18,7 @@
|
||||
#include <maxscale/semaphore.h>
|
||||
#include <maxscale/spinlock.h>
|
||||
#include <maxscale/thread.h>
|
||||
#include <maxscale/query_classifier.h>
|
||||
|
||||
/**
|
||||
* @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.");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user