Merge branch '2.1' into 2.2
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
#include <maxscale/semaphore.h>
|
||||
#include <maxscale/spinlock.h>
|
||||
#include <maxscale/thread.h>
|
||||
#include <maxscale/query_classifier.h>
|
||||
#include <maxscale/json_api.h>
|
||||
|
||||
/**
|
||||
@ -52,20 +53,30 @@ static THREAD hk_thr_handle;
|
||||
|
||||
static void hkthread(void *);
|
||||
|
||||
bool hkinit()
|
||||
struct hkinit_result
|
||||
{
|
||||
bool inited = false;
|
||||
sem_t sem;
|
||||
bool ok;
|
||||
};
|
||||
|
||||
if (thread_start(&hk_thr_handle, hkthread, NULL, 0) != NULL)
|
||||
bool
|
||||
hkinit()
|
||||
{
|
||||
struct hkinit_result res;
|
||||
sem_init(&res.sem, 0, 0);
|
||||
res.ok = false;
|
||||
|
||||
if (thread_start(&hk_thr_handle, hkthread, &res, 0) != NULL)
|
||||
{
|
||||
inited = true;
|
||||
sem_wait(&res.sem);
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ALERT("Failed to start housekeeper thread.");
|
||||
}
|
||||
|
||||
return inited;
|
||||
sem_destroy(&res.sem);
|
||||
return res.ok;
|
||||
}
|
||||
|
||||
int hktask_add(const char *name, void (*taskfn)(void *), void *data, int frequency)
|
||||
@ -214,6 +225,16 @@ void 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++)
|
||||
@ -253,6 +274,7 @@ void hkthread(void *data)
|
||||
spinlock_release(&tasklock);
|
||||
}
|
||||
|
||||
qc_thread_end(QC_INIT_BOTH);
|
||||
MXS_NOTICE("Housekeeper shutting down.");
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ size_t datetime_sizes[] =
|
||||
*/
|
||||
static void unpack_datetime(uint8_t *ptr, int length, struct tm *dest)
|
||||
{
|
||||
int64_t val = 0;
|
||||
uint64_t val = 0;
|
||||
uint32_t second, minute, hour, day, month, year;
|
||||
|
||||
if (length == -1)
|
||||
@ -717,6 +717,7 @@ size_t unpack_decimal_field(uint8_t *ptr, uint8_t *metadata, double *val_float)
|
||||
int fpart2 = decimals - fpart1 * dec_dig;
|
||||
int ibytes = ipart1 * 4 + dig_bytes[ipart2];
|
||||
int fbytes = fpart1 * 4 + dig_bytes[fpart2];
|
||||
int field_size = ibytes + fbytes;
|
||||
|
||||
/** Remove the sign bit and store it locally */
|
||||
bool negative = (ptr[0] & 0x80) == 0;
|
||||
@ -735,7 +736,17 @@ size_t unpack_decimal_field(uint8_t *ptr, uint8_t *metadata, double *val_float)
|
||||
}
|
||||
}
|
||||
|
||||
int64_t val_i = unpack_bytes(ptr, ibytes);
|
||||
int64_t val_i = 0;
|
||||
|
||||
if (ibytes > 8)
|
||||
{
|
||||
int extra = ibytes - 8;
|
||||
ptr += extra;
|
||||
ibytes -= extra;
|
||||
ss_dassert(ibytes == 8);
|
||||
}
|
||||
|
||||
val_i = unpack_bytes(ptr, ibytes);
|
||||
int64_t val_f = fbytes ? unpack_bytes(ptr + ibytes, fbytes) : 0;
|
||||
|
||||
if (negative)
|
||||
@ -746,5 +757,5 @@ size_t unpack_decimal_field(uint8_t *ptr, uint8_t *metadata, double *val_float)
|
||||
|
||||
*val_float = (double)val_i + ((double)val_f / (pow(10.0, decimals)));
|
||||
|
||||
return ibytes + fbytes;
|
||||
return field_size;
|
||||
}
|
||||
|
@ -20,6 +20,11 @@
|
||||
#include <maxscale/maxscale_test.h>
|
||||
#include <maxscale/log_manager.h>
|
||||
#include <maxscale/config.h>
|
||||
#include <maxscale/query_classifier.h>
|
||||
#include <maxscale/paths.h>
|
||||
#include <maxscale/alloc.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "../internal/poll.h"
|
||||
#include "../internal/statistics.h"
|
||||
@ -28,15 +33,17 @@
|
||||
|
||||
void init_test_env(char *path)
|
||||
{
|
||||
int argc = 3;
|
||||
|
||||
const char* logdir = path ? path : TEST_LOG_DIR;
|
||||
|
||||
config_get_global_options()->n_threads = 1;
|
||||
|
||||
ts_stats_init();
|
||||
mxs_log_init(NULL, logdir, MXS_LOG_TARGET_DEFAULT);
|
||||
if (!mxs_log_init(NULL, NULL, MXS_LOG_TARGET_STDOUT))
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
dcb_global_init();
|
||||
set_libdir(MXS_STRDUP(TEST_DIR "/query_classifier/qc_sqlite/"));
|
||||
qc_setup(NULL, QC_SQL_MODE_DEFAULT, NULL);
|
||||
qc_process_init(QC_INIT_BOTH);
|
||||
poll_init();
|
||||
maxscale::MessageQueue::init();
|
||||
maxscale::Worker::init();
|
||||
|
Reference in New Issue
Block a user