Merge branch 'develop' into 1.2.1-binlog_router_trx
This commit is contained in:
@ -73,7 +73,10 @@
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <pcre.h>
|
||||
|
||||
/** According to the PCRE manual, this should be a multiple of 3 */
|
||||
#define MAXSCALE_PCRE_BUFSZ 24
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
@ -125,6 +128,57 @@ char *ptr;
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove extra commas and whitespace from a string. This string is interpreted
|
||||
* as a list of string values separated by commas.
|
||||
* @param strptr String to clean
|
||||
* @return pointer to a new string or NULL if an error occurred
|
||||
*/
|
||||
char* config_clean_string_list(char* str)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
if((tmp = malloc(sizeof(char)*(strlen(str) + 1))) != NULL)
|
||||
{
|
||||
char *ptr;
|
||||
int match[MAXSCALE_PCRE_BUFSZ];
|
||||
pcre* re;
|
||||
const char *re_err;
|
||||
int err_offset,rval;
|
||||
|
||||
|
||||
tmp[0] = '\0';
|
||||
|
||||
if((re = pcre_compile("\\s*+([^,]*[^,\\s])",0,&re_err,&err_offset,NULL)) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"[%s] Error: Regular expression compilation failed at %d: %s",
|
||||
__FUNCTION__,err_offset,re_err);
|
||||
free(tmp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ptr = str;
|
||||
|
||||
while((rval = pcre_exec(re,NULL,ptr,strlen(ptr),0,0,(int*)&match,MAXSCALE_PCRE_BUFSZ)) > 1)
|
||||
{
|
||||
const char* substr;
|
||||
|
||||
pcre_get_substring(ptr,(int*)&match,rval,1,&substr);
|
||||
if(strlen(tmp) > 0)
|
||||
strcat(tmp,",");
|
||||
strcat(tmp,substr);
|
||||
pcre_free_substring(substr);
|
||||
ptr = &ptr[match[1]];
|
||||
}
|
||||
pcre_free(re);
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LE,"[%s] Error: Memory allocation failed.",__FUNCTION__);
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
/**
|
||||
* Config item handler for the ini file reader
|
||||
*
|
||||
@ -174,12 +228,24 @@ CONFIG_PARAMETER *param, *p1;
|
||||
{
|
||||
if (!strcmp(p1->name, name))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Configuration object '%s' has multiple "
|
||||
"parameters names '%s'.",
|
||||
ptr->object, name)));
|
||||
return 0;
|
||||
char *tmp;
|
||||
int paramlen = strlen(p1->value) + strlen(value) + 2;
|
||||
|
||||
if((tmp = realloc(p1->value,sizeof(char) * (paramlen))) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"[%s] Error: Memory allocation failed.",__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
strcat(tmp,",");
|
||||
strcat(tmp,value);
|
||||
if((p1->value = config_clean_string_list(tmp)) == NULL)
|
||||
{
|
||||
p1->value = tmp;
|
||||
skygw_log_write(LE,"[%s] Error: Cleaning configuration parameter failed.",__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
free(tmp);
|
||||
return 1;
|
||||
}
|
||||
p1 = p1->next;
|
||||
}
|
||||
@ -205,7 +271,7 @@ int
|
||||
config_load(char *file)
|
||||
{
|
||||
CONFIG_CONTEXT config;
|
||||
int rval;
|
||||
int rval, ini_rval;
|
||||
|
||||
MYSQL *conn;
|
||||
conn = mysql_init(NULL);
|
||||
@ -248,8 +314,23 @@ int rval;
|
||||
config.object = "";
|
||||
config.next = NULL;
|
||||
|
||||
if (ini_parse(file, handler, &config) < 0)
|
||||
if (( ini_rval = ini_parse(file, handler, &config)) != 0)
|
||||
{
|
||||
char errorbuffer[1024 + 1];
|
||||
|
||||
if (ini_rval > 0)
|
||||
snprintf(errorbuffer, sizeof(errorbuffer),
|
||||
"Error: Failed to parse configuration file. Error on line %d.", ini_rval);
|
||||
else if(ini_rval == -1)
|
||||
snprintf(errorbuffer, sizeof(errorbuffer),
|
||||
"Error: Failed to parse configuration file. Failed to open file.");
|
||||
else
|
||||
snprintf(errorbuffer, sizeof(errorbuffer),
|
||||
"Error: Failed to parse configuration file. Memory allocation failed.");
|
||||
|
||||
skygw_log_write(LE, errorbuffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
config_file = file;
|
||||
|
||||
|
@ -160,6 +160,8 @@ static bool libmysqld_started = FALSE;
|
||||
*/
|
||||
static bool daemon_mode = true;
|
||||
|
||||
static const char* maxscale_commit = MAXSCALE_COMMIT;
|
||||
|
||||
const char *progname = NULL;
|
||||
static struct option long_options[] = {
|
||||
{"homedir", required_argument, 0, 'c'},
|
||||
@ -178,6 +180,7 @@ static struct option long_options[] = {
|
||||
{"user",required_argument,0,'U'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{"help", no_argument, 0, '?'},
|
||||
{"version-full", no_argument, 0, 'V'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
static int cnf_preparser(void* data, const char* section, const char* name, const char* value);
|
||||
@ -388,12 +391,16 @@ sigfatal_handler (int i)
|
||||
_exit(1);
|
||||
}
|
||||
fatal_handling = 1;
|
||||
|
||||
fprintf(stderr, "\n\nMaxScale received fatal signal %d\n", i);
|
||||
GATEWAY_CONF* cnf = config_get_global_options();
|
||||
fprintf(stderr, "\n\nMaxScale "MAXSCALE_VERSION" received fatal signal %d\n", i);
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Fatal: MaxScale received fatal signal %d. Attempting backtrace.", i)));
|
||||
"Fatal: MaxScale "MAXSCALE_VERSION" received fatal signal %d. Attempting backtrace.", i)));
|
||||
|
||||
skygw_log_write_flush(LE,"Commit ID: %s System name: %s "
|
||||
"Release string: %s Embedded library version: %s",
|
||||
maxscale_commit, cnf->sysname, cnf->release_string, cnf->version_string);
|
||||
|
||||
{
|
||||
void *addrs[128];
|
||||
@ -1011,6 +1018,7 @@ static void usage(void)
|
||||
" -s, --syslog=[yes|no] log messages to syslog (default:yes)\n"
|
||||
" -S, --maxscalelog=[yes|no] log messages to MaxScale log (default: yes)\n"
|
||||
" -v, --version print version info and exit\n"
|
||||
" -V, --version-full print full version info and exit\n"
|
||||
" -?, --help show this help\n"
|
||||
, progname);
|
||||
}
|
||||
@ -1051,6 +1059,7 @@ int main(int argc, char **argv)
|
||||
int l;
|
||||
int i;
|
||||
int n;
|
||||
int ini_rval;
|
||||
intptr_t thread_id;
|
||||
int n_threads; /*< number of epoll listener threads */
|
||||
int n_services;
|
||||
@ -1113,7 +1122,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "dc:f:l:vs:S:?L:D:C:B:U:A:P:",
|
||||
while ((opt = getopt_long(argc, argv, "dc:f:l:vVs:S:?L:D:C:B:U:A:P:",
|
||||
long_options, &option_index)) != -1)
|
||||
{
|
||||
bool succp = true;
|
||||
@ -1148,8 +1157,13 @@ int main(int argc, char **argv)
|
||||
|
||||
case 'v':
|
||||
rc = EXIT_SUCCESS;
|
||||
printf("%s\n",MAXSCALE_VERSION);
|
||||
goto return_main;
|
||||
printf("MaxScale %s\n", MAXSCALE_VERSION);
|
||||
goto return_main;
|
||||
|
||||
case 'V':
|
||||
rc = EXIT_SUCCESS;
|
||||
printf("MaxScale %s - %s\n", MAXSCALE_VERSION, maxscale_commit);
|
||||
goto return_main;
|
||||
|
||||
case 'l':
|
||||
if (strncasecmp(optarg, "file", PATH_MAX) == 0)
|
||||
@ -1587,8 +1601,27 @@ int main(int argc, char **argv)
|
||||
goto return_main;
|
||||
}
|
||||
|
||||
if(ini_parse(cnf_file_path,cnf_preparser,NULL) != 0)
|
||||
if((ini_rval = ini_parse(cnf_file_path, cnf_preparser,NULL)) != 0)
|
||||
{
|
||||
char errorbuffer[STRING_BUFFER_SIZE];
|
||||
|
||||
if(ini_rval > 0)
|
||||
snprintf(errorbuffer, sizeof(errorbuffer),
|
||||
"Error: Failed to pre-parse configuration file. Error on line %d.", ini_rval);
|
||||
else if(ini_rval == -1)
|
||||
snprintf(errorbuffer, sizeof(errorbuffer),
|
||||
"Error: Failed to pre-parse configuration file. Failed to open file.");
|
||||
else
|
||||
snprintf(errorbuffer, sizeof(errorbuffer),
|
||||
"Error: Failed to pre-parse configuration file. Memory allocation failed.");
|
||||
|
||||
skygw_log_write(LE, errorbuffer);
|
||||
if(!daemon_mode)
|
||||
{
|
||||
strncat(errorbuffer, "\n", STRING_BUFFER_SIZE);
|
||||
fprintf(stderr, errorbuffer);
|
||||
}
|
||||
|
||||
rc = MAXSCALE_BADCONFIG;
|
||||
goto return_main;
|
||||
}
|
||||
|
@ -1 +1,2 @@
|
||||
#define MAXSCALE_VERSION "@MAXSCALE_VERSION@"
|
||||
#define MAXSCALE_COMMIT "@MAXSCALE_COMMIT@"
|
||||
|
@ -1,2 +1,2 @@
|
||||
add_definitions(-DINI_MAX_LINE=1024)
|
||||
add_definitions(-DINI_MAX_LINE=1024 -DINI_ALLOW_MULTILINE)
|
||||
add_library(inih ini.c)
|
||||
|
@ -551,6 +551,18 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
rc = 0;
|
||||
goto return_rc;
|
||||
}
|
||||
|
||||
if (!read_buffer) {
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"%lu [gw_read_backend_event] "
|
||||
"Read buffer unexpectedly null, even though response "
|
||||
"not marked as complete. User: %s",
|
||||
pthread_self(),
|
||||
current_session->user)));
|
||||
rc = 0;
|
||||
goto return_rc;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check that session is operable, and that client DCB is
|
||||
@ -1562,9 +1574,10 @@ static GWBUF* process_response_data (
|
||||
* enough data to read the packet length.
|
||||
*/
|
||||
init_response_status(readbuf, srvcmd, &npackets_left, &nbytes_left);
|
||||
initial_packets = npackets_left;
|
||||
initial_bytes = nbytes_left;
|
||||
}
|
||||
|
||||
initial_packets = npackets_left;
|
||||
initial_bytes = nbytes_left;
|
||||
}
|
||||
/** Only session commands with responses should be processed */
|
||||
ss_dassert(npackets_left > 0);
|
||||
|
@ -731,8 +731,8 @@ int gw_send_authentication_to_backend(
|
||||
|
||||
rv = dcb_write(dcb, buffer);
|
||||
|
||||
if (rv < 0) {
|
||||
return rv;
|
||||
if (rv == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user