Merge branch 'develop' of https://github.com/mariadb-corporation/MaxScale into develop
This commit is contained in:
commit
9dfa4378b4
@ -40,8 +40,8 @@ configure_file(${CMAKE_SOURCE_DIR}/server/test/maxscale_test.h.in ${CMAKE_BINARY
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/postinst.in ${CMAKE_BINARY_DIR}/postinst)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/postrm.in ${CMAKE_BINARY_DIR}/postrm)
|
||||
|
||||
set(CMAKE_C_FLAGS "-Wall -fPIC")
|
||||
set(CMAKE_CXX_FLAGS "-Wall -fPIC")
|
||||
set(CMAKE_C_FLAGS "-Wall -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function -fPIC")
|
||||
set(CMAKE_CXX_FLAGS "-Wall -Wno-unused-variable -Wno-unused-but-set-variable -fPIC")
|
||||
set(DEBUG_FLAGS "-ggdb -pthread -pipe -Wformat -fstack-protector --param=ssp-buffer-size=4")
|
||||
|
||||
if(CMAKE_VERSION VERSION_GREATER 2.6)
|
||||
|
@ -167,7 +167,7 @@ struct logfile_st {
|
||||
size_t lf_file_size;
|
||||
/** list of block-sized log buffers */
|
||||
mlist_t lf_blockbuf_list;
|
||||
int lf_buf_size;
|
||||
size_t lf_buf_size;
|
||||
bool lf_flushflag;
|
||||
bool lf_rotateflag;
|
||||
int lf_spinlock; /**< lf_flushflag & lf_rotateflag */
|
||||
@ -633,7 +633,7 @@ static int logmanager_write_log(
|
||||
int err = 0;
|
||||
blockbuf_t* bb;
|
||||
blockbuf_t* bb_c;
|
||||
int timestamp_len;
|
||||
size_t timestamp_len;
|
||||
int i;
|
||||
|
||||
CHK_LOGMANAGER(lm);
|
||||
@ -680,9 +680,9 @@ static int logmanager_write_log(
|
||||
else
|
||||
{
|
||||
/** Length of string that will be written, limited by bufsize */
|
||||
int safe_str_len;
|
||||
size_t safe_str_len;
|
||||
/** Length of session id */
|
||||
int sesid_str_len;
|
||||
size_t sesid_str_len;
|
||||
|
||||
/**
|
||||
* 2 braces, 2 spaces and terminating char
|
||||
@ -2335,7 +2335,6 @@ static bool check_file_and_path(
|
||||
bool* writable,
|
||||
bool do_log)
|
||||
{
|
||||
int fd;
|
||||
bool exists;
|
||||
|
||||
if (filename == NULL)
|
||||
@ -2349,112 +2348,54 @@ static bool check_file_and_path(
|
||||
}
|
||||
else
|
||||
{
|
||||
fd = open(filename, O_CREAT|O_EXCL, S_IRWXU);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
/** File exists, check permission to read/write */
|
||||
if (errno == EEXIST)
|
||||
{
|
||||
/** Open file and write a byte for test */
|
||||
fd = open(filename, O_CREAT|O_RDWR, S_IRWXU|S_IRWXG);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
if (do_log && file_is_symlink(filename))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"*\n* Error : Can't access "
|
||||
"file pointed to by %s due "
|
||||
"to %s.\n",
|
||||
filename,
|
||||
strerror(errno));
|
||||
}
|
||||
else if (do_log)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"*\n* Error : Can't access %s due "
|
||||
"to %s.\n",
|
||||
filename,
|
||||
strerror(errno));
|
||||
}
|
||||
if (writable)
|
||||
{
|
||||
*writable = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (writable)
|
||||
{
|
||||
char c = ' ';
|
||||
if (write(fd, &c, 1) == 1)
|
||||
{
|
||||
*writable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (do_log &&
|
||||
file_is_symlink(filename))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"*\n* Error : Can't write to "
|
||||
"file pointed to by %s due to "
|
||||
"%s.\n",
|
||||
filename,
|
||||
strerror(errno));
|
||||
}
|
||||
else if (do_log)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"*\n* Error : Can't write to "
|
||||
"%s due to %s.\n",
|
||||
filename,
|
||||
strerror(errno));
|
||||
}
|
||||
*writable = false;
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
exists = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (do_log && file_is_symlink(filename))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"*\n* Error : Can't access the file "
|
||||
"pointed to by %s due to %s.\n",
|
||||
filename,
|
||||
strerror(errno));
|
||||
}
|
||||
else if (do_log)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"*\n* Error : Can't access %s due to %s.\n",
|
||||
filename,
|
||||
strerror(errno));
|
||||
}
|
||||
exists = false;
|
||||
|
||||
if (writable)
|
||||
{
|
||||
*writable = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
close(fd);
|
||||
unlink(filename);
|
||||
exists = false;
|
||||
|
||||
if (writable)
|
||||
{
|
||||
*writable = true;
|
||||
}
|
||||
}
|
||||
if(access(filename,F_OK) == 0)
|
||||
{
|
||||
|
||||
exists = true;
|
||||
|
||||
if(access(filename,W_OK) == 0)
|
||||
{
|
||||
if(writable)
|
||||
{
|
||||
*writable = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (do_log && file_is_symlink(filename))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"*\n* Error : Can't access "
|
||||
"file pointed to by %s due "
|
||||
"to %s.\n",
|
||||
filename,
|
||||
strerror(errno));
|
||||
}
|
||||
else if (do_log)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"*\n* Error : Can't access %s due "
|
||||
"to %s.\n",
|
||||
filename,
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
if(writable)
|
||||
{
|
||||
*writable = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
exists = false;
|
||||
if(writable)
|
||||
{
|
||||
*writable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
|
@ -1253,7 +1253,7 @@ char* skygw_get_affected_fields(GWBUF* buf)
|
||||
|
||||
List_iterator<Item> ilist(lex->current_select->item_list);
|
||||
item = (Item*)ilist.next();
|
||||
for (item; item != NULL; item=(Item*)ilist.next())
|
||||
for (; item != NULL; item=(Item*)ilist.next())
|
||||
{
|
||||
|
||||
itype = item->type();
|
||||
@ -1572,7 +1572,7 @@ char* skygw_get_qtype_str(
|
||||
skygw_query_op_t query_classifier_get_operation(GWBUF* querybuf)
|
||||
{
|
||||
LEX* lex = get_lex(querybuf);
|
||||
skygw_query_op_t operation;
|
||||
skygw_query_op_t operation = QUERY_OP_UNDEFINED;
|
||||
if(lex){
|
||||
switch(lex->sql_command){
|
||||
case SQLCOM_SELECT:
|
||||
|
@ -158,6 +158,7 @@ int sendMessage(MYSQL* server, amqp_message_t* msg)
|
||||
(int)((msg->properties.correlation_id.len + 1)*2+1) +
|
||||
strlen(DB_INSERT),
|
||||
rval = 0;
|
||||
char* saved;
|
||||
char *qstr = calloc(buffsz,sizeof(char)),
|
||||
*rawmsg = calloc((msg->body.len + 1),sizeof(char)),
|
||||
*clnmsg = calloc(((msg->body.len + 1)*2+1),sizeof(char)),
|
||||
@ -170,9 +171,9 @@ int sendMessage(MYSQL* server, amqp_message_t* msg)
|
||||
|
||||
sprintf(qstr,"%.*s",(int)msg->body.len,(char *)msg->body.bytes);
|
||||
fprintf(out_fd,"Received: %s\n",qstr);
|
||||
char *ptr = strtok(qstr,"|");
|
||||
char *ptr = strtok_r(qstr,"|",&saved);
|
||||
sprintf(rawdate,"%s",ptr);
|
||||
ptr = strtok(NULL,"\n\0");
|
||||
ptr = strtok_r(NULL,"\n\0",&saved);
|
||||
if(ptr == NULL){
|
||||
fprintf(out_fd,"Message content not valid.\n");
|
||||
rval = 1;
|
||||
|
@ -991,7 +991,7 @@ static void usage(void)
|
||||
" -f|--config=... relative|absolute pathname of MaxScale configuration file\n"
|
||||
" (default: $MAXSCALE_HOME/etc/MaxScale.cnf)\n"
|
||||
" -l|--log=... log to file or shared memory\n"
|
||||
" -lfile or -lshm - defaults to shared memory\n"
|
||||
" -lfile or -lshm - defaults to file\n"
|
||||
" -v|--version print version info and exit\n"
|
||||
" -?|--help show this help\n"
|
||||
, progname);
|
||||
@ -1039,6 +1039,7 @@ int main(int argc, char **argv)
|
||||
int l;
|
||||
int i;
|
||||
int n;
|
||||
intptr_t thread_id;
|
||||
int n_threads; /*< number of epoll listener threads */
|
||||
int n_services;
|
||||
int eno = 0; /*< local variable for errno */
|
||||
@ -1052,7 +1053,7 @@ int main(int argc, char **argv)
|
||||
char* cnf_file_arg = NULL; /*< conf filename from cmd-line arg */
|
||||
void* log_flush_thr = NULL;
|
||||
int option_index;
|
||||
int logtofile = 0; /* Use shared memory or file */
|
||||
int logtofile = 1; /* Use shared memory or file */
|
||||
ssize_t log_flush_timeout_ms = 0;
|
||||
sigset_t sigset;
|
||||
sigset_t sigpipe_mask;
|
||||
@ -1788,9 +1789,9 @@ int main(int argc, char **argv)
|
||||
/*<
|
||||
* Start server threads.
|
||||
*/
|
||||
for (n = 0; n < n_threads - 1; n++)
|
||||
for (thread_id = 0; thread_id < n_threads - 1; thread_id++)
|
||||
{
|
||||
threads[n] = thread_start(poll_waitevents, (void *)(n + 1));
|
||||
threads[thread_id] = thread_start(poll_waitevents, (void *)(thread_id + 1));
|
||||
}
|
||||
LOGIF(LM, (skygw_log_write(LOGFILE_MESSAGE,
|
||||
"MaxScale started with %d server threads.",
|
||||
@ -1803,9 +1804,9 @@ int main(int argc, char **argv)
|
||||
/*<
|
||||
* Wait server threads' completion.
|
||||
*/
|
||||
for (n = 0; n < n_threads - 1; n++)
|
||||
for (thread_id = 0; thread_id < n_threads - 1; thread_id++)
|
||||
{
|
||||
thread_wait(threads[n]);
|
||||
thread_wait(threads[thread_id]);
|
||||
}
|
||||
/*<
|
||||
* Wait the flush thread.
|
||||
|
@ -678,12 +678,14 @@ void *key, *value;
|
||||
if (!(*keywrite)(fd, key))
|
||||
{
|
||||
close(fd);
|
||||
hashtable_iterator_free(iter);
|
||||
return -1;
|
||||
}
|
||||
if ((value = hashtable_fetch(table, key)) == NULL ||
|
||||
(*valuewrite)(fd, value) == 0)
|
||||
{
|
||||
close(fd);
|
||||
hashtable_iterator_free(iter);
|
||||
return -1;
|
||||
}
|
||||
rval++;
|
||||
@ -691,10 +693,13 @@ void *key, *value;
|
||||
}
|
||||
|
||||
/* Now go back and write the count of entries */
|
||||
lseek(fd, 7L, SEEK_SET);
|
||||
write(fd, &rval, sizeof(rval));
|
||||
|
||||
if(lseek(fd, 7L, SEEK_SET) != -1)
|
||||
{
|
||||
write(fd, &rval, sizeof(rval));
|
||||
}
|
||||
|
||||
close(fd);
|
||||
hashtable_iterator_free(iter);
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <stdio.h>
|
||||
#include <secrets.h>
|
||||
|
||||
main(int argc, char **argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
|
@ -28,10 +28,12 @@
|
||||
* @endverbatim
|
||||
*/
|
||||
#include <memlog.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static MEMLOG *memlogs = NULL;
|
||||
static SPINLOCK *memlock = SPINLOCK_INIT;
|
||||
static SPINLOCK memlock = SPINLOCK_INIT;
|
||||
|
||||
/**
|
||||
* Create a new instance of a memory logger.
|
||||
|
@ -237,7 +237,7 @@ char *
|
||||
modutil_get_SQL(GWBUF *buf)
|
||||
{
|
||||
unsigned int len, length;
|
||||
unsigned char *ptr, *dptr, *rval = NULL;
|
||||
char *ptr, *dptr, *rval = NULL;
|
||||
|
||||
if (!modutil_is_SQL(buf))
|
||||
return rval;
|
||||
@ -671,4 +671,4 @@ static void modutil_reply_routing_error(
|
||||
/** Create an incoming event for backend DCB */
|
||||
poll_add_epollin_event_to_dcb(backend_dcb, buf);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ poll_waitevents(void *arg)
|
||||
{
|
||||
struct epoll_event events[MAX_EVENTS];
|
||||
int i, nfds, timeout_bias = 1;
|
||||
int thread_id = (int)arg;
|
||||
intptr_t thread_id = (intptr_t)arg;
|
||||
DCB *zombies = NULL;
|
||||
int poll_spins = 0;
|
||||
|
||||
|
@ -221,7 +221,7 @@ GWPROTOCOL *funcs;
|
||||
|
||||
{
|
||||
/* Try loading authentication data from file cache */
|
||||
char *ptr, path[4096];
|
||||
char *ptr, path[4097];
|
||||
strcpy(path, "/usr/local/skysql/MaxScale");
|
||||
if ((ptr = getenv("MAXSCALE_HOME")) != NULL)
|
||||
{
|
||||
@ -251,6 +251,7 @@ GWPROTOCOL *funcs;
|
||||
{
|
||||
/* Save authentication data to file cache */
|
||||
char *ptr, path[4096];
|
||||
int mkdir_rval = 0;
|
||||
strcpy(path, "/usr/local/skysql/MaxScale");
|
||||
if ((ptr = getenv("MAXSCALE_HOME")) != NULL)
|
||||
{
|
||||
@ -259,10 +260,33 @@ GWPROTOCOL *funcs;
|
||||
strncat(path, "/", 4096);
|
||||
strncat(path, service->name, 4096);
|
||||
if (access(path, R_OK) == -1)
|
||||
mkdir(path, 0777);
|
||||
{
|
||||
mkdir_rval = mkdir(path, 0777);
|
||||
}
|
||||
|
||||
if(mkdir_rval)
|
||||
{
|
||||
skygw_log_write(LOGFILE_ERROR,"Error : Failed to create directory '%s': [%d] %s",
|
||||
path,
|
||||
errno,
|
||||
strerror(errno));
|
||||
mkdir_rval = 0;
|
||||
}
|
||||
|
||||
strncat(path, "/.cache", 4096);
|
||||
if (access(path, R_OK) == -1)
|
||||
mkdir(path, 0777);
|
||||
{
|
||||
mkdir_rval = mkdir(path, 0777);
|
||||
}
|
||||
|
||||
if(mkdir_rval)
|
||||
{
|
||||
skygw_log_write(LOGFILE_ERROR,"Error : Failed to create directory '%s': [%d] %s",
|
||||
path,
|
||||
errno,
|
||||
strerror(errno));
|
||||
mkdir_rval = 0;
|
||||
}
|
||||
strncat(path, "/dbusers", 4096);
|
||||
dbusers_save(service->users, path);
|
||||
}
|
||||
|
@ -637,8 +637,9 @@ void link_rules(char* rule, FW_INSTANCE* instance)
|
||||
|
||||
/**Apply rules to users*/
|
||||
|
||||
bool match_any;
|
||||
bool match_any = true;
|
||||
char *tok, *ruleptr, *userptr, *modeptr;
|
||||
char *saveptr = NULL;
|
||||
RULELIST* rulelist = NULL;
|
||||
|
||||
userptr = strstr(rule,"users ");
|
||||
@ -653,10 +654,10 @@ void link_rules(char* rule, FW_INSTANCE* instance)
|
||||
|
||||
*modeptr++ = '\0';
|
||||
*ruleptr++ = '\0';
|
||||
|
||||
tok = strtok(modeptr," ");
|
||||
if(strcmp(tok,"match") == 0){
|
||||
tok = strtok(NULL," ");
|
||||
|
||||
tok = strtok_r(modeptr," ",&saveptr);
|
||||
if(tok && strcmp(tok,"match") == 0){
|
||||
tok = strtok_r(NULL," ",&saveptr);
|
||||
if(strcmp(tok,"any") == 0){
|
||||
match_any = true;
|
||||
}else if(strcmp(tok,"all") == 0){
|
||||
@ -667,8 +668,8 @@ void link_rules(char* rule, FW_INSTANCE* instance)
|
||||
}
|
||||
}
|
||||
|
||||
tok = strtok(ruleptr," ");
|
||||
tok = strtok(NULL," ");
|
||||
tok = strtok_r(ruleptr," ",&saveptr);
|
||||
tok = strtok_r(NULL," ",&saveptr);
|
||||
|
||||
while(tok)
|
||||
{
|
||||
@ -682,7 +683,7 @@ void link_rules(char* rule, FW_INSTANCE* instance)
|
||||
rulelist = tmp_rl;
|
||||
|
||||
}
|
||||
tok = strtok(NULL," ");
|
||||
tok = strtok_r(NULL," ",&saveptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -690,8 +691,8 @@ void link_rules(char* rule, FW_INSTANCE* instance)
|
||||
*/
|
||||
|
||||
*(ruleptr) = '\0';
|
||||
userptr = strtok(rule," ");
|
||||
userptr = strtok(NULL," ");
|
||||
userptr = strtok_r(rule," ",&saveptr);
|
||||
userptr = strtok_r(NULL," ",&saveptr);
|
||||
|
||||
while(userptr)
|
||||
{
|
||||
@ -738,10 +739,16 @@ void link_rules(char* rule, FW_INSTANCE* instance)
|
||||
(void *)userptr,
|
||||
(void *)user);
|
||||
|
||||
userptr = strtok(NULL," ");
|
||||
userptr = strtok_r(NULL," ",&saveptr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
while(rulelist)
|
||||
{
|
||||
RULELIST *tmp = rulelist;
|
||||
rulelist = rulelist->next;
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -755,7 +762,8 @@ void parse_rule(char* rule, FW_INSTANCE* instance)
|
||||
ss_dassert(rule != NULL && instance != NULL);
|
||||
|
||||
char *rulecpy = strdup(rule);
|
||||
char *tok = strtok(rulecpy," ,");
|
||||
char *saveptr = NULL;
|
||||
char *tok = strtok_r(rulecpy," ,",&saveptr);
|
||||
bool allow,deny,mode;
|
||||
RULE* ruledef = NULL;
|
||||
|
||||
@ -763,7 +771,7 @@ void parse_rule(char* rule, FW_INSTANCE* instance)
|
||||
|
||||
if(strcmp("rule",tok) == 0){ /**Define a new rule*/
|
||||
|
||||
tok = strtok(NULL," ,");
|
||||
tok = strtok_r(NULL," ,",&saveptr);
|
||||
|
||||
if(tok == NULL) goto retblock;
|
||||
|
||||
@ -798,8 +806,13 @@ void parse_rule(char* rule, FW_INSTANCE* instance)
|
||||
add_users(rule, instance);
|
||||
goto retblock;
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LOGFILE_ERROR,"Error : Unknown token in rule file: %s",tok);
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
tok = strtok(NULL, " ,");
|
||||
tok = strtok_r(NULL, " ,",&saveptr);
|
||||
|
||||
|
||||
if((allow = (strcmp(tok,"allow") == 0)) ||
|
||||
@ -808,7 +821,7 @@ void parse_rule(char* rule, FW_INSTANCE* instance)
|
||||
mode = allow ? true:false;
|
||||
ruledef->allow = mode;
|
||||
ruledef->type = RT_PERMISSION;
|
||||
tok = strtok(NULL, " ,");
|
||||
tok = strtok_r(NULL, " ,",&saveptr);
|
||||
|
||||
|
||||
while(tok){
|
||||
@ -820,13 +833,13 @@ void parse_rule(char* rule, FW_INSTANCE* instance)
|
||||
{
|
||||
STRLINK *tail = NULL,*current;
|
||||
ruledef->type = RT_COLUMN;
|
||||
tok = strtok(NULL, " ,");
|
||||
tok = strtok_r(NULL, " ,",&saveptr);
|
||||
while(tok && strcmp(tok,"at_times") != 0){
|
||||
current = malloc(sizeof(STRLINK));
|
||||
current->value = strdup(tok);
|
||||
current->next = tail;
|
||||
tail = current;
|
||||
tok = strtok(NULL, " ,");
|
||||
tok = strtok_r(NULL, " ,",&saveptr);
|
||||
}
|
||||
|
||||
ruledef->data = (void*)tail;
|
||||
@ -836,7 +849,7 @@ void parse_rule(char* rule, FW_INSTANCE* instance)
|
||||
else if(strcmp(tok,"at_times") == 0)
|
||||
{
|
||||
|
||||
tok = strtok(NULL, " ,");
|
||||
tok = strtok_r(NULL, " ,",&saveptr);
|
||||
TIMERANGE *tr = NULL;
|
||||
while(tok){
|
||||
TIMERANGE *tmp = parse_time(tok,instance);
|
||||
@ -846,7 +859,7 @@ void parse_rule(char* rule, FW_INSTANCE* instance)
|
||||
}
|
||||
tmp->next = tr;
|
||||
tr = tmp;
|
||||
tok = strtok(NULL, " ,");
|
||||
tok = strtok_r(NULL, " ,",&saveptr);
|
||||
}
|
||||
ruledef->active = tr;
|
||||
}
|
||||
@ -855,7 +868,7 @@ void parse_rule(char* rule, FW_INSTANCE* instance)
|
||||
bool escaped = false;
|
||||
regex_t *re;
|
||||
char* start, *str;
|
||||
tok = strtok(NULL," ");
|
||||
tok = strtok_r(NULL," ",&saveptr);
|
||||
char delim = '\'';
|
||||
while(*tok == '\'' || *tok == '"'){
|
||||
delim = *tok;
|
||||
@ -914,20 +927,20 @@ void parse_rule(char* rule, FW_INSTANCE* instance)
|
||||
qs->id = ++instance->idgen;
|
||||
spinlock_release(instance->lock);
|
||||
|
||||
tok = strtok(NULL," ");
|
||||
tok = strtok_r(NULL," ",&saveptr);
|
||||
if(tok == NULL){
|
||||
free(qs);
|
||||
goto retblock;
|
||||
}
|
||||
qs->limit = atoi(tok);
|
||||
|
||||
tok = strtok(NULL," ");
|
||||
tok = strtok_r(NULL," ",&saveptr);
|
||||
if(tok == NULL){
|
||||
free(qs);
|
||||
goto retblock;
|
||||
}
|
||||
qs->period = atof(tok);
|
||||
tok = strtok(NULL," ");
|
||||
tok = strtok_r(NULL," ",&saveptr);
|
||||
if(tok == NULL){
|
||||
free(qs);
|
||||
goto retblock;
|
||||
@ -943,7 +956,7 @@ void parse_rule(char* rule, FW_INSTANCE* instance)
|
||||
}
|
||||
else if(strcmp(tok,"on_operations") == 0)
|
||||
{
|
||||
tok = strtok(NULL," ");
|
||||
tok = strtok_r(NULL," ",&saveptr);
|
||||
if(!parse_querytypes(tok,ruledef)){
|
||||
skygw_log_write(LOGFILE_ERROR,
|
||||
"fwfilter: Invalid query type"
|
||||
@ -951,7 +964,7 @@ void parse_rule(char* rule, FW_INSTANCE* instance)
|
||||
,tok);
|
||||
}
|
||||
}
|
||||
tok = strtok(NULL," ,");
|
||||
tok = strtok_r(NULL," ,",&saveptr);
|
||||
}
|
||||
|
||||
goto retblock;
|
||||
|
@ -11,6 +11,7 @@ add_executable(harness harness_util.c harness_common.c ${CORE})
|
||||
target_link_libraries(harness_ui fullcore log_manager utils)
|
||||
target_link_libraries(harness fullcore)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${ERRMSG} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/harness.cnf ${CMAKE_CURRENT_BINARY_DIR})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testdriver.sh ${CMAKE_CURRENT_BINARY_DIR}/testdriver.sh @ONLY)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hintfilter/hint_testing.cnf ${CMAKE_CURRENT_BINARY_DIR}/hintfilter/hint_testing.cnf)
|
||||
|
@ -141,6 +141,7 @@ FILTER_PARAMETER** read_params(int* paramc)
|
||||
{
|
||||
char buffer[256];
|
||||
char* token;
|
||||
char* saveptr;
|
||||
char* names[64];
|
||||
char* values[64];
|
||||
int pc = 0, do_read = 1, val_len = 0;
|
||||
@ -157,14 +158,14 @@ FILTER_PARAMETER** read_params(int* paramc)
|
||||
if(strcmp("done\n",buffer) == 0){
|
||||
do_read = 0;
|
||||
}else{
|
||||
token = strtok(buffer,"=\n");
|
||||
token = strtok_r(buffer,"=\n",&saveptr);
|
||||
if(token!=NULL){
|
||||
val_len = strcspn(token," \n\0");
|
||||
if((names[pc] = calloc((val_len + 1),sizeof(char))) != NULL){
|
||||
memcpy(names[pc],token,val_len);
|
||||
}
|
||||
}
|
||||
token = strtok(NULL,"=\n");
|
||||
token = strtok_r(NULL,"=\n",&saveptr);
|
||||
if(token!=NULL){
|
||||
val_len = strcspn(token," \n\0");
|
||||
if((values[pc] = calloc((val_len + 1),sizeof(char))) != NULL){
|
||||
@ -997,6 +998,7 @@ int process_opts(int argc, char** argv)
|
||||
int fd, buffsize = 1024;
|
||||
int rd,rdsz, rval = 0, error = 0;
|
||||
size_t fsize;
|
||||
char* saveptr;
|
||||
char *buff = calloc(buffsize,sizeof(char)), *tok = NULL;
|
||||
|
||||
/**Parse 'harness.cnf' file*/
|
||||
@ -1027,16 +1029,16 @@ int process_opts(int argc, char** argv)
|
||||
instance.session_count = 1;
|
||||
rdsz = read(fd,buff,fsize);
|
||||
buff[rdsz] = '\0';
|
||||
tok = strtok(buff,"=");
|
||||
tok = strtok_r(buff,"=",&saveptr);
|
||||
while(tok){
|
||||
if(!strcmp(tok,"threads")){
|
||||
tok = strtok(NULL,"\n\0");
|
||||
tok = strtok_r(NULL,"\n\0",&saveptr);
|
||||
instance.thrcount = strtol(tok,0,0);
|
||||
}else if(!strcmp(tok,"sessions")){
|
||||
tok = strtok(NULL,"\n\0");
|
||||
tok = strtok_r(NULL,"\n\0",&saveptr);
|
||||
instance.session_count = strtol(tok,0,0);
|
||||
}
|
||||
tok = strtok(NULL,"=");
|
||||
tok = strtok_r(NULL,"=",&saveptr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,7 +20,6 @@ int main(int argc, char** argv){
|
||||
printf("\n\n\tFilter Test Harness\n\n");
|
||||
}
|
||||
|
||||
|
||||
while(instance.running){
|
||||
printf("Harness> ");
|
||||
memset(buffer,0,256);
|
||||
|
@ -488,8 +488,11 @@ char *ptr;
|
||||
}
|
||||
|
||||
static int
|
||||
cmp_topn(TOPNQ **a, TOPNQ **b)
|
||||
cmp_topn(const void *va, const void *vb)
|
||||
{
|
||||
TOPNQ **a = (TOPNQ **)va;
|
||||
TOPNQ **b = (TOPNQ **)vb;
|
||||
|
||||
if ((*b)->duration.tv_sec == (*a)->duration.tv_sec)
|
||||
return (*b)->duration.tv_usec - (*a)->duration.tv_usec;
|
||||
return (*b)->duration.tv_sec - (*a)->duration.tv_sec;
|
||||
|
Loading…
x
Reference in New Issue
Block a user