Merge branch 'develop' into 1.2.1-binlog_router_trx

This commit is contained in:
MassimilianoPinto 2015-09-03 10:08:55 +02:00
commit 506bc422fb
14 changed files with 497 additions and 288 deletions

View File

@ -38,6 +38,7 @@ find_package(MySQL)
find_package(Pandoc)
find_package(TCMalloc)
find_package(Jemalloc)
find_package(Git)
find_package(CURL)
# You can find the variables set by this in the FindCURL.cmake file
# which is a default module in CMake.
@ -56,6 +57,18 @@ else()
endif()
endif()
if(GIT_FOUND)
message(STATUS "Found git ${GIT_VERSION_STRING}")
execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --max-count=1 HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT)
string(REPLACE "\n" "" MAXSCALE_COMMIT ${GIT_COMMIT})
message(STATUS "Commit ID: ${MAXSCALE_COMMIT}")
else()
message(WARNING "Could not find git, MaxScale commit ID will not be resolved. Will use 'source-build' for commit ID.")
set(MAXSCALE_COMMIT "source-build")
endif()
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/${MAXSCALE_LIBDIR})
# Make sure the release notes for this release are present if it is a stable one

View File

@ -33,7 +33,18 @@ The MaxScale configuration is read from a file which can be located in a number
An explicit path to a configuration file can be passed by using the `-f` option to MaxScale.
The configuration file itself is based on the ".ini" file format and consists of various sections that are used to build the configuration, these sections define services, servers, listeners, monitors and global settings.
The configuration file itself is based on the ".ini" file format and consists of various sections that are used to build the configuration, these sections define services, servers, listeners, monitors and global settings. Parameters which expect a comma-separated list of values can be defined on multiple lines. The following is an example of a multi-line definition.
```
[MyService]
type=service
router=readconnroute
servers=server1,
server2,
server3
```
The values of the parameter that are not on the first line need to have at least one whitespace character before them in order for them to be recognized as a part of the multi-line parameter.
Please see the section about [Protocol Modules](#protocol-modules) for more details about MaxScale and the default directories where modules will be searched for.

View File

@ -44,6 +44,7 @@ Switch|Long Option|Description
`-s [yes no]`|`--syslog=[yes no]`|log messages to syslog (default:yes)
`-S [yes no]`|`--maxscalelog=[yes no]`|log messages to MaxScale log (default: yes)
`-v`|`--version`|print version info and exit
`-V`|`--version-full`|print version info and the commit ID the binary was built from
`-?`|`--help`|show this help
<a name="stopping"></a>

View File

@ -56,6 +56,9 @@ Log messages to MaxScale's own log files.
.BR "-v, --version"
Print version information and exit.
.TP
.BR "-V, --version-full"
Print full version information including the Git commit the binary was built from and exit.
.TP
.BR "-?, --help"
Show the help information for MaxScale and exit.

View File

@ -58,6 +58,35 @@ start() {
CHECK_RET=$?
[ $CHECK_RET -eq 0 ] && echo -n " found $my_check" && success && CHECK_RET=0
if [ ! -d @MAXSCALE_VARDIR@/log/maxscale ]
then
mkdir -p @MAXSCALE_VARDIR@/log/maxscale
fi
if [ ! -d @MAXSCALE_VARDIR@/cache/maxscale ]
then
mkdir -p @MAXSCALE_VARDIR@/cache/maxscale
fi
if [ ! -d @MAXSCALE_VARDIR@/lib/maxscale ]
then
mkdir -p @MAXSCALE_VARDIR@/lib/maxscale
fi
if [ ! -d @MAXSCALE_VARDIR@/run/maxscale ]
then
mkdir -p @MAXSCALE_VARDIR@/run/maxscale
fi
chown maxscale:maxscale @MAXSCALE_VARDIR@/log/maxscale
chown maxscale:maxscale @MAXSCALE_VARDIR@/lib/maxscale
chown maxscale:maxscale @MAXSCALE_VARDIR@/cache/maxscale
chown maxscale:maxscale @MAXSCALE_VARDIR@/run/maxscale
chmod 0755 @MAXSCALE_VARDIR@/log/maxscale
chmod 0755 @MAXSCALE_VARDIR@/lib/maxscale
chmod 0755 @MAXSCALE_VARDIR@/cache/maxscale
chmod 0755 @MAXSCALE_VARDIR@/run/maxscale
daemon --pidfile $MAXSCALE_PIDFILE @CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale --user=maxscale >& /dev/null
RETVAL=$?

View File

@ -56,6 +56,36 @@ servicename=maxscale
RETVAL=0
start() {
if [ ! -d @MAXSCALE_VARDIR@/log/maxscale ]
then
mkdir -p @MAXSCALE_VARDIR@/log/maxscale
fi
if [ ! -d @MAXSCALE_VARDIR@/cache/maxscale ]
then
mkdir -p @MAXSCALE_VARDIR@/cache/maxscale
fi
if [ ! -d @MAXSCALE_VARDIR@/lib/maxscale ]
then
mkdir -p @MAXSCALE_VARDIR@/lib/maxscale
fi
if [ ! -d @MAXSCALE_VARDIR@/run/maxscale ]
then
mkdir -p @MAXSCALE_VARDIR@/run/maxscale
fi
chown maxscale:maxscale @MAXSCALE_VARDIR@/log/maxscale
chown maxscale:maxscale @MAXSCALE_VARDIR@/lib/maxscale
chown maxscale:maxscale @MAXSCALE_VARDIR@/cache/maxscale
chown maxscale:maxscale @MAXSCALE_VARDIR@/run/maxscale
chmod 0755 @MAXSCALE_VARDIR@/log/maxscale
chmod 0755 @MAXSCALE_VARDIR@/lib/maxscale
chmod 0755 @MAXSCALE_VARDIR@/cache/maxscale
chmod 0755 @MAXSCALE_VARDIR@/run/maxscale
log_daemon_msg "Starting MaxScale"
start_daemon -p "$MAXSCALE_PIDFILE" "$DAEMON" "$DAEMON_OPTS" 2> /dev/null > /dev/null

File diff suppressed because it is too large Load Diff

View File

@ -50,13 +50,13 @@ typedef struct log_info_st
size_t li_sesid;
int li_enabled_logs;
} log_info_t;
#define LE LOGFILE_ERROR
#define LM LOGFILE_MESSAGE
#define LT LOGFILE_TRACE
#define LD LOGFILE_DEBUG
/**
/**
* Check if specified log type is enabled in general or if it is enabled
* for the current session.
*/
@ -75,11 +75,11 @@ typedef struct log_info_st
{ \
cmd; \
}
/**
* Execute the given command if specified log is enabled in general or
* if the log is enabled for the current session.
*/
*/
#define LOGIF(id,cmd) if (LOG_IS_ENABLED(id)) \
{ \
cmd; \
@ -99,7 +99,7 @@ typedef struct log_info_st
* RUN Struct is valid for run-time checking.
* DONE means that possible memory allocations have been released.
*/
typedef enum { UNINIT = 0, INIT, RUN, DONE } flat_obj_state_t;
typedef enum { UNINIT = 0, INIT, RUN, DONE } flat_obj_state_t;
EXTERN_C_BLOCK_BEGIN

View File

@ -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;

View 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;
}

View File

@ -1 +1,2 @@
#define MAXSCALE_VERSION "@MAXSCALE_VERSION@"
#define MAXSCALE_COMMIT "@MAXSCALE_COMMIT@"

View File

@ -1,2 +1,2 @@
add_definitions(-DINI_MAX_LINE=1024)
add_definitions(-DINI_MAX_LINE=1024 -DINI_ALLOW_MULTILINE)
add_library(inih ini.c)

View File

@ -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);

View File

@ -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;
}