From 45c3b453ec54ae93f82cc3bd53294fc25aced4ee Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 24 Apr 2015 17:47:30 +0300 Subject: [PATCH 01/42] Changed PID file to /data instead of /log --- server/core/gateway.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/core/gateway.c b/server/core/gateway.c index 69191a978..ed69d3e3e 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -2015,7 +2015,7 @@ static int write_pid_file(char *home_dir) { int fd = -1; - snprintf(pidfile, PATH_MAX, "%s/log/maxscale.pid", home_dir); + snprintf(pidfile, PATH_MAX, "%s/data/maxscale.pid", home_dir); fd = open(pidfile, O_WRONLY | O_CREAT | O_TRUNC, 0777); if (fd == -1) { From 62ebf542d58127ff9a6bffd309ed8b2cfcb759b5 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 24 Apr 2015 17:56:59 +0300 Subject: [PATCH 02/42] Revert "Changed PID file to /data instead of /log" This reverts commit 45c3b453ec54ae93f82cc3bd53294fc25aced4ee. --- server/core/gateway.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/core/gateway.c b/server/core/gateway.c index ed69d3e3e..69191a978 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -2015,7 +2015,7 @@ static int write_pid_file(char *home_dir) { int fd = -1; - snprintf(pidfile, PATH_MAX, "%s/data/maxscale.pid", home_dir); + snprintf(pidfile, PATH_MAX, "%s/log/maxscale.pid", home_dir); fd = open(pidfile, O_WRONLY | O_CREAT | O_TRUNC, 0777); if (fd == -1) { From fdca25db9f1db6cc8cd4ff65a71718d31c4ec860 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 24 Apr 2015 17:57:00 +0300 Subject: [PATCH 03/42] Revert "modutil_get_complete_packets now partially clones the buffer instead of allocating a new one." This reverts commit b62f7f942bde10ea7d69d933c03513e315891d02. --- server/core/modutil.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/core/modutil.c b/server/core/modutil.c index 82890e334..a0afb5622 100644 --- a/server/core/modutil.c +++ b/server/core/modutil.c @@ -549,6 +549,7 @@ GWBUF* modutil_get_complete_packets(GWBUF** p_readbuf) packet->next = NULL; *p_readbuf = packet; ptr = (uint8_t*)packet->start; + end = (uint8_t*)packet->end; len = gw_mysql_get_byte3(ptr) + 4; blen = gwbuf_length(packet); @@ -577,13 +578,18 @@ GWBUF* modutil_get_complete_packets(GWBUF** p_readbuf) } /** The next packet is a partial, split into complete and partial packets */ - if((buff = gwbuf_clone_portion(packet,0,total)) == NULL) + if((buff = gwbuf_alloc(total)) == NULL) { skygw_log_write(LOGFILE_ERROR, - "Error: Failed to partially clone buffer."); + "Error: Failed to allocate new buffer " + " of %d bytes while splitting buffer" + " into complete packets.", + total); return NULL; } - + buff->next = NULL; + gwbuf_set_type(buff,GWBUF_TYPE_MYSQL); + memcpy(buff->start,packet->start,total); gwbuf_consume(packet,total); return buff; } From 5c96676ea0ab240fd3786b4eade380529fa2afef Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 24 Apr 2015 17:57:01 +0300 Subject: [PATCH 04/42] Revert "Removed obsolete log directory in MAXSCALE_HOME." This reverts commit d7b665b8675e305390b401a228053a648a1e20e6. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94842ebaa..685a49e55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,6 +149,7 @@ install(FILES ${ERRMSG} DESTINATION mysql) install(FILES ${CMAKE_SOURCE_DIR}/COPYRIGHT DESTINATION .) install(FILES ${CMAKE_SOURCE_DIR}/README DESTINATION .) install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION .) +install(DIRECTORY DESTINATION log) # Install startup scripts and ldconfig files if(WITH_SCRIPTS) From bbdfc3a5a7de0008a01e0a50f4ffa96b567735e6 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 24 Apr 2015 17:57:29 +0300 Subject: [PATCH 05/42] Revert "Merge branch 'develop' of https://github.com/mariadb-corporation/MaxScale into develop" This reverts commit 58e85098f931f6337841b25126fad23b579a9b49, reversing changes made to c89c7047053f0d6f89069d1b6da2f9caa856066b. --- server/modules/routing/binlog/blr_file.c | 35 ++---------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/server/modules/routing/binlog/blr_file.c b/server/modules/routing/binlog/blr_file.c index b8e201227..482449fc1 100644 --- a/server/modules/routing/binlog/blr_file.c +++ b/server/modules/routing/binlog/blr_file.c @@ -164,24 +164,6 @@ blr_file_rotate(ROUTER_INSTANCE *router, char *file, uint64_t pos) } -/** - * binlog files need an initial 4 magic bytes at the start. blr_file_add_magic() - * adds them. - * - * @param router The router instance - * @param fd file descriptor to the open binlog file - * @return Nothing - */ -static void -blr_file_add_magic(ROUTER_INSTANCE *router, int fd) -{ -unsigned char magic[] = BINLOG_MAGIC; - - write(fd, magic, 4); - router->binlog_position = 4; /* Initial position after the magic number */ -} - - /** * Create a new binlog file for the router to use. * @@ -194,6 +176,7 @@ blr_file_create(ROUTER_INSTANCE *router, char *file) { char path[1024]; int fd; +unsigned char magic[] = BINLOG_MAGIC; strcpy(path, router->binlogdir); strcat(path, "/"); @@ -201,7 +184,7 @@ int fd; if ((fd = open(path, O_RDWR|O_CREAT, 0666)) != -1) { - blr_file_add_magic(router,fd); + write(fd, magic, 4); } else { @@ -214,7 +197,7 @@ int fd; close(router->binlog_fd); spinlock_acquire(&router->binlog_lock); strncpy(router->binlog_name, file,BINLOG_FNAMELEN); - blr_file_add_magic(router, fd); + router->binlog_position = 4; /* Initial position after the magic number */ spinlock_release(&router->binlog_lock); router->binlog_fd = fd; return 1; @@ -249,18 +232,6 @@ int fd; spinlock_acquire(&router->binlog_lock); strncpy(router->binlog_name, file,BINLOG_FNAMELEN); router->binlog_position = lseek(fd, 0L, SEEK_END); - if (router->binlog_position < 4) { - if (router->binlog_position == 0) { - blr_file_add_magic(router, fd); - } else { - /* If for any reason the file's length is between 1 and 3 bytes - * then report an error. */ - LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, - "%s: binlog file %s has an invalid length %d.", - router->service->name, path, router->binlog_position))); - return; - } - } spinlock_release(&router->binlog_lock); router->binlog_fd = fd; } From c9e2632bb8c25ccdd7f555e853799c3bcc9f5b16 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 24 Apr 2015 17:57:41 +0300 Subject: [PATCH 06/42] Revert "MXS-117: https://mariadb.atlassian.net/browse/MXS-117" This reverts commit c89c7047053f0d6f89069d1b6da2f9caa856066b. --- server/MaxScale_template.cnf | 6 +- server/core/gateway.c | 163 +++++------------------------------ server/inih/CMakeLists.txt | 3 +- 3 files changed, 25 insertions(+), 147 deletions(-) diff --git a/server/MaxScale_template.cnf b/server/MaxScale_template.cnf index 7038ac387..feec5695d 100644 --- a/server/MaxScale_template.cnf +++ b/server/MaxScale_template.cnf @@ -2,14 +2,10 @@ # # Global parameters # -# Number of worker threads in MaxScale. +# Number of worker threads in MaxScale # # threads= # -# Directory for the MaxScale log files. Default is /var/log/maxscale/. -# -# logdir= -# # Enabled logfiles. The message log is enabled by default and # the error log is always enabled. # diff --git a/server/core/gateway.c b/server/core/gateway.c index 69191a978..7fda1017d 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -74,8 +74,6 @@ #include -#include - /** for procname */ #if !defined(_GNU_SOURCE) # define _GNU_SOURCE @@ -115,11 +113,6 @@ const int num_elements = (sizeof(server_options) / sizeof(char *)) - 1; const char* default_cnf_fname = "etc/MaxScale.cnf"; -const char* default_configdir = "/etc/"; -const char* default_logdir = "/var/log/maxscale/"; -const char* default_libdir = "/lib64/maxscale/lib/"; -const char* default_moddir = "/lib64/maxscale/modules/"; - static char* server_groups[] = { "embedded", "server", @@ -136,10 +129,6 @@ static char datadir[PATH_MAX+1] = ""; /* The data directory we created for this gateway instance */ static char pidfile[PATH_MAX+1] = ""; -static char* configdir = NULL; -static char* logdir = NULL; -static char* libdir = NULL; -static char* moddir = NULL; /** * exit flag for log flusher. */ @@ -161,14 +150,13 @@ static struct option long_options[] = { {"config", required_argument, 0, 'f'}, {"nodaemon", no_argument, 0, 'd'}, {"log", required_argument, 0, 'l'}, - {"logdir", required_argument, 0, 'L'}, {"syslog", required_argument, 0, 's'}, {"maxscalelog", required_argument, 0, 'S'}, {"version", no_argument, 0, 'v'}, {"help", no_argument, 0, '?'}, {0, 0, 0, 0} }; -static int cnf_preparser(void* data, const char* section, const char* name, const char* value); + static void log_flush_shutdown(void); static void log_flush_cb(void* arg); static int write_pid_file(char *); /* write MaxScale pidfile */ @@ -180,7 +168,6 @@ static void write_footer(void); static int ntfw_cb(const char*, const struct stat*, int, struct FTW*); static bool file_is_readable(char* absolute_pathname); static bool file_is_writable(char* absolute_pathname); -bool handle_path_arg(char** dest, char* path, char* arg, bool rd, bool wr); static void usage(void); static char* get_expanded_pathname( char** abs_path, @@ -199,7 +186,7 @@ static bool resolve_maxscale_conf_fname( static bool resolve_maxscale_homedir( char** p_home_dir); -static char* check_dir_access(char* dirname,bool,bool); +static char* check_dir_access(char* dirname); /** * Handler for SIGHUP signal. Reload the configuration for the @@ -741,9 +728,8 @@ return_succp: * read or write is not permitted. */ static char* check_dir_access( - char* dirname, bool rd, bool wr) + char* dirname) { - char errbuf[PATH_MAX*2]; char* errstr = NULL; if (dirname == NULL) @@ -751,27 +737,18 @@ static char* check_dir_access( errstr = strdup("Directory argument is NULL"); goto retblock; } - - if(access(dirname,F_OK) != 0) + + if (!file_is_readable(dirname)) { - sprintf(errbuf,"Can't access '%s'.",dirname); - errstr = strdup(errbuf); - goto retblock; - } - - if (rd && !file_is_readable(dirname)) - { - sprintf(errbuf,"MaxScale doesn't have read permission " - "to '%s'.",dirname); - errstr = strdup(errbuf); + errstr = strdup("MaxScale doesn't have read permission " + "to MAXSCALE_HOME."); goto retblock; } - if (wr && !file_is_writable(dirname)) + if (!file_is_writable(dirname)) { - sprintf(errbuf,"MaxScale doesn't have write permission " - "to '%s'.",dirname); - errstr = strdup(errbuf); + errstr = strdup("MaxScale doesn't have write permission " + "to MAXSCALE_HOME. Exiting."); goto retblock; } @@ -1021,8 +998,6 @@ static void usage(void) " (default: $MAXSCALE_HOME/etc/MaxScale.cnf)\n" " -l|--log=... log to file or shared memory\n" " -lfile or -lshm - defaults to shared memory\n" - " -L|--logdir=... path to log file directory\n" - " (default: /var/log/maxscale)\n" " -s|--syslog= log messages to syslog." " True or false - defaults to true\n" " -S|--maxscalelog= log messages to MaxScale log." @@ -1087,8 +1062,6 @@ int main(int argc, char **argv) char* cnf_file_path = NULL; /*< conf file, to be freed */ char* cnf_file_arg = NULL; /*< conf filename from cmd-line arg */ void* log_flush_thr = NULL; - char* tmp_path; - char* tmp_var; int option_index; int logtofile = 0; /* Use shared memory or file */ int syslog_enabled = 1; /** Log to syslog */ @@ -1132,8 +1105,7 @@ int main(int argc, char **argv) goto return_main; } } - - while ((opt = getopt_long(argc, argv, "dc:f:l:vs:S:?L:", + while ((opt = getopt_long(argc, argv, "dc:f:l:vs:S:?", long_options, &option_index)) != -1) { bool succp = true; @@ -1238,14 +1210,6 @@ int main(int argc, char **argv) succp = false; } break; - case 'L': - - if(handle_path_arg(&tmp_path,optarg,NULL,true,false)) - { - logdir = tmp_path; - } - - break; case 'S': if(strstr(optarg,"=")) { @@ -1568,7 +1532,7 @@ int main(int argc, char **argv) char* log_context = strdup("Home directory command-line argument"); char* errstr; - errstr = check_dir_access(home_dir,true,true); + errstr = check_dir_access(home_dir); if (errstr != NULL) { @@ -1602,12 +1566,6 @@ int main(int argc, char **argv) free(log_context); } - char pbuf[PATH_MAX]; - - sprintf(pbuf,"%s/etc/MaxScale.cnf",home_dir); - - ini_parse(pbuf,cnf_preparser,NULL); - /** * Init Log Manager for MaxScale. * If $MAXSCALE_HOME is set then write the logs into $MAXSCALE_HOME/log. @@ -1619,27 +1577,22 @@ int main(int argc, char **argv) char buf[1024]; char *argv[8]; bool succp; + /** Set log directory under $MAXSCALE_HOME/log */ + sprintf(buf, "%s/log", home_dir); - /** Use default log directory /var/log/maxscale/ */ - if(logdir == NULL) + if(mkdir(buf, 0777) != 0) { - - if(access(default_logdir,F_OK) != 0) - { - if(mkdir(logdir,0555) != 0) + if(errno != EEXIST) { - fprintf(stderr, - "Error: Cannot create log directory: %s\n", - default_logdir); - goto return_main; + fprintf(stderr, + "Error: Cannot create log directory: %s\n", + buf); + goto return_main; } - } - logdir = strdup(default_logdir); } - argv[0] = "MaxScale"; argv[1] = "-j"; - argv[2] = logdir; + argv[2] = buf; if(!syslog_enabled) { @@ -1722,11 +1675,11 @@ int main(int argc, char **argv) fprintf(stderr, "Home directory : %s" "\nConfiguration file : %s" - "\nLog directory : %s" + "\nLog directory : %s/log" "\nData directory : %s\n\n", home_dir, cnf_file_path, - logdir, + home_dir, datadir); } LOGIF(LM, (skygw_log_write_flush( @@ -2050,73 +2003,3 @@ MaxScaleUptime() { return time(0) - MaxScaleStarted; } - -bool handle_path_arg(char** dest, char* path, char* arg, bool rd, bool wr) -{ - char pathbuffer[PATH_MAX+2]; - char* errstr; - bool rval = false; - - if(path == NULL && arg == NULL) - return rval; - - if(path) - { - snprintf(pathbuffer,PATH_MAX,"%s",path); - if(pathbuffer[strlen(path) - 1] != '/') - { - strcat(pathbuffer,"/"); - } - if(arg && strlen(pathbuffer) + strlen(arg) + 1 < PATH_MAX) - strcat(pathbuffer,arg); - - if((errstr = check_dir_access(pathbuffer,rd,wr)) == NULL) - { - *dest = strdup(pathbuffer); - rval = true; - } - else - { - fprintf(stderr,"%s\n",errstr); - free(errstr); - errstr = NULL; - } - } - - return rval; -} - -/** - * Pre-parse the MaxScale.cnf for config, log and module directories. - * @param data Parameter passed by inih - * @param section Section name - * @param name Parameter name - * @param value Parameter value - * @return 1 in all cases - */ -static int cnf_preparser(void* data, const char* section, const char* name, const char* value) -{ - - char pathbuffer[PATH_MAX]; - char* errstr; - - if(strcasecmp(section,"maxscale") == 0) - { - if(strcmp(name, "logdir") == 0) - { - /** logdir is only NULL if no command line parameter was given */ - if(logdir == NULL) - handle_path_arg(&logdir,(char*)value,NULL,true,true); - } - else if(strcmp(name, "moddir") == 0) - { - handle_path_arg(&moddir,(char*)value,NULL,true,false); - } - else if(strcmp(name, "libdir") == 0) - { - handle_path_arg(&libdir,(char*)value,NULL,true,false); - } - } - - return 1; -} \ No newline at end of file diff --git a/server/inih/CMakeLists.txt b/server/inih/CMakeLists.txt index 0b07fcfbf..24393e05d 100644 --- a/server/inih/CMakeLists.txt +++ b/server/inih/CMakeLists.txt @@ -1,2 +1 @@ -add_library(inih ini.c) -target_compile_definitions(inih PUBLIC INI_MAX_LINE=1024) +add_library(inih ini.c) \ No newline at end of file From 89b75cb510641c0325737555687516a39f2a4538 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Sun, 26 Apr 2015 11:41:02 +0300 Subject: [PATCH 07/42] Added FindJemalloc.cmake --- CMakeLists.txt | 2 +- cmake/FindJemalloc.cmake | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 cmake/FindJemalloc.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 685a49e55..03cf42f49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ find_package(MySQLClient) find_package(MySQL) find_package(Pandoc) find_package(TCMalloc) - +find_package(Jemalloc) # You can find the variables set by this in the FindCURL.cmake file # which is a default module in CMake. find_package(CURL) diff --git a/cmake/FindJemalloc.cmake b/cmake/FindJemalloc.cmake new file mode 100644 index 000000000..3bea2d5a0 --- /dev/null +++ b/cmake/FindJemalloc.cmake @@ -0,0 +1,11 @@ +# this CMake file defines the following variables +# JEMALLOC_FOUND - Jemalloc was found +# JEMALLOC_LIBRARIES - Jemalloc library +find_library(JEMALLOC_LIBRARIES NAMES jemalloc libjemalloc.so.4 libjemalloc.so.4.2.2) +if(JEMALLOC_LIBRARIES) + set(JEMALLOC_FOUND TRUE CACHE INTERNAL "") + message(STATUS "Found libjemalloc: ${JEMALLOC_LIBRARIES}") +else() + set(JEMALLOC_FOUND FALSE CACHE INTERNAL "") + message(STATUS "Could not find libjemalloc, using system default malloc instead.") +endif() From 16044f5201edfe4bd6e9611a3ba04b69d4810e16 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 27 Apr 2015 05:57:16 +0300 Subject: [PATCH 08/42] Added optional jemalloc linkage. --- server/core/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/core/CMakeLists.txt b/server/core/CMakeLists.txt index 630d4c034..03e874ac2 100644 --- a/server/core/CMakeLists.txt +++ b/server/core/CMakeLists.txt @@ -1,7 +1,9 @@ if(BUILD_TESTS OR BUILD_TOOLS) file(GLOB FULLCORE_SRC *.c) add_library(fullcore STATIC ${FULLCORE_SRC}) - if(WITH_TCMALLOC) + if(WITH_JEMALLOC) + target_link_libraries(fullcore ${JEMALLOC_LIBRARIES}) + elseif(WITH_TCMALLOC) target_link_libraries(fullcore ${TCMALLOC_LIBRARIES}) endif() target_link_libraries(fullcore ${CURL_LIBRARIES} log_manager utils pthread ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} ssl aio rt crypt dl crypto inih z m stdc++) @@ -13,7 +15,9 @@ add_executable(maxscale atomic.c buffer.c spinlock.c gateway.c monitor.c adminusers.c secrets.c filter.c modutil.c hint.c housekeeper.c memlog.c resultset.c) -if(WITH_TCMALLOC) +if(WITH_JEMALLOC) + target_link_libraries(maxscale ${JEMALLOC_LIBRARIES}) +elseif(WITH_TCMALLOC) target_link_libraries(maxscale ${TCMALLOC_LIBRARIES}) endif() From af7567d4053ff33f38b784ea27f995489c923b95 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 27 Apr 2015 09:43:22 +0300 Subject: [PATCH 09/42] Switched over to gwbuf_clone_portion in modutils_get_complete_packets. --- server/core/modutil.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/server/core/modutil.c b/server/core/modutil.c index a0afb5622..60ad6c1b2 100644 --- a/server/core/modutil.c +++ b/server/core/modutil.c @@ -538,7 +538,7 @@ return_packetbuf: GWBUF* modutil_get_complete_packets(GWBUF** p_readbuf) { GWBUF *buff = NULL, *packet; - uint8_t *ptr,*end; + uint8_t *ptr; int len,blen,total = 0; if(p_readbuf == NULL || (*p_readbuf) == NULL || @@ -549,7 +549,6 @@ GWBUF* modutil_get_complete_packets(GWBUF** p_readbuf) packet->next = NULL; *p_readbuf = packet; ptr = (uint8_t*)packet->start; - end = (uint8_t*)packet->end; len = gw_mysql_get_byte3(ptr) + 4; blen = gwbuf_length(packet); @@ -578,18 +577,12 @@ GWBUF* modutil_get_complete_packets(GWBUF** p_readbuf) } /** The next packet is a partial, split into complete and partial packets */ - if((buff = gwbuf_alloc(total)) == NULL) + if((buff = gwbuf_clone_portion(packet,0,total)) == NULL) { skygw_log_write(LOGFILE_ERROR, - "Error: Failed to allocate new buffer " - " of %d bytes while splitting buffer" - " into complete packets.", - total); + "Error: Failed to partially clone buffer."); return NULL; } - buff->next = NULL; - gwbuf_set_type(buff,GWBUF_TYPE_MYSQL); - memcpy(buff->start,packet->start,total); gwbuf_consume(packet,total); return buff; } From 5974935f65c6e579aa174c21b5f517833db88f17 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 27 Apr 2015 10:10:55 +0300 Subject: [PATCH 10/42] Removed file globbing in the core CMake file and used explicit names instead. --- server/core/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/core/CMakeLists.txt b/server/core/CMakeLists.txt index 03e874ac2..820df49d1 100644 --- a/server/core/CMakeLists.txt +++ b/server/core/CMakeLists.txt @@ -1,6 +1,5 @@ if(BUILD_TESTS OR BUILD_TOOLS) - file(GLOB FULLCORE_SRC *.c) - add_library(fullcore STATIC ${FULLCORE_SRC}) + add_library(fullcore STATIC adminusers.c atomic.c config.c dbusers.c dcb.c filter.c gwbitmask.c gw_utils.c hashtable.c hint.c housekeeper.c load_utils.c memlog.x modutil.c monitor.c poll.c resultset.c secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c) if(WITH_JEMALLOC) target_link_libraries(fullcore ${JEMALLOC_LIBRARIES}) elseif(WITH_TCMALLOC) From 61ebb0fe978eadea166c0a4e58df464200810ae4 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 27 Apr 2015 10:14:47 +0300 Subject: [PATCH 11/42] Fixed a typo in the core CMakeLists.txt --- server/core/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/core/CMakeLists.txt b/server/core/CMakeLists.txt index 820df49d1..72946402c 100644 --- a/server/core/CMakeLists.txt +++ b/server/core/CMakeLists.txt @@ -1,5 +1,5 @@ if(BUILD_TESTS OR BUILD_TOOLS) - add_library(fullcore STATIC adminusers.c atomic.c config.c dbusers.c dcb.c filter.c gwbitmask.c gw_utils.c hashtable.c hint.c housekeeper.c load_utils.c memlog.x modutil.c monitor.c poll.c resultset.c secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c) + add_library(fullcore STATIC adminusers.c atomic.c config.c dbusers.c dcb.c filter.c gwbitmask.c gw_utils.c hashtable.c hint.c housekeeper.c load_utils.c memlog.c modutil.c monitor.c poll.c resultset.c secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c) if(WITH_JEMALLOC) target_link_libraries(fullcore ${JEMALLOC_LIBRARIES}) elseif(WITH_TCMALLOC) From 6f1fe003a334baa4cac107a2c41bf79f06ad102d Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 27 Apr 2015 10:17:55 +0300 Subject: [PATCH 12/42] Added missing buffer.c from fullcore static lib. --- server/core/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/core/CMakeLists.txt b/server/core/CMakeLists.txt index 72946402c..db5e79e8c 100644 --- a/server/core/CMakeLists.txt +++ b/server/core/CMakeLists.txt @@ -1,5 +1,5 @@ if(BUILD_TESTS OR BUILD_TOOLS) - add_library(fullcore STATIC adminusers.c atomic.c config.c dbusers.c dcb.c filter.c gwbitmask.c gw_utils.c hashtable.c hint.c housekeeper.c load_utils.c memlog.c modutil.c monitor.c poll.c resultset.c secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c) + add_library(fullcore STATIC adminusers.c atomic.c config.c buffer.c dbusers.c dcb.c filter.c gwbitmask.c gw_utils.c hashtable.c hint.c housekeeper.c load_utils.c memlog.c modutil.c monitor.c poll.c resultset.c secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c) if(WITH_JEMALLOC) target_link_libraries(fullcore ${JEMALLOC_LIBRARIES}) elseif(WITH_TCMALLOC) From 1f21540f8c916b548d1dc117bc16f43ae86693d4 Mon Sep 17 00:00:00 2001 From: Simon J Mudd Date: Thu, 23 Apr 2015 20:26:56 +0200 Subject: [PATCH 13/42] Make MaxScale handle zero-length files to aid bootstrapping. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When bootstrapping a binlog router to start it needs to know the first file to use. You can provide this information in the config file but that will never be up to date, or you can copy a file to the binlog server and start maxscale. It will then carry on from the last file’s current position. The binlog files have a 4-byte magic prefix so to start from the beginning (position 4) you need to add these to an empty file if you do this by hand. If you don’t then maxscale will attempt to download from the master at position 0 and the master will not accept this value. (This is not apparent with a mysql client as change master to … master_log_pos = 0 triggers a write of the 4 magic bytes and then asks the master for information from position 4 [not 0]). This patch makes MaxScale behave similarly and allows you to only need to touch the first binlog file to be downloaded for it to do the right thing. --- server/modules/routing/binlog/blr_file.c | 35 ++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/server/modules/routing/binlog/blr_file.c b/server/modules/routing/binlog/blr_file.c index 482449fc1..b8e201227 100644 --- a/server/modules/routing/binlog/blr_file.c +++ b/server/modules/routing/binlog/blr_file.c @@ -164,6 +164,24 @@ blr_file_rotate(ROUTER_INSTANCE *router, char *file, uint64_t pos) } +/** + * binlog files need an initial 4 magic bytes at the start. blr_file_add_magic() + * adds them. + * + * @param router The router instance + * @param fd file descriptor to the open binlog file + * @return Nothing + */ +static void +blr_file_add_magic(ROUTER_INSTANCE *router, int fd) +{ +unsigned char magic[] = BINLOG_MAGIC; + + write(fd, magic, 4); + router->binlog_position = 4; /* Initial position after the magic number */ +} + + /** * Create a new binlog file for the router to use. * @@ -176,7 +194,6 @@ blr_file_create(ROUTER_INSTANCE *router, char *file) { char path[1024]; int fd; -unsigned char magic[] = BINLOG_MAGIC; strcpy(path, router->binlogdir); strcat(path, "/"); @@ -184,7 +201,7 @@ unsigned char magic[] = BINLOG_MAGIC; if ((fd = open(path, O_RDWR|O_CREAT, 0666)) != -1) { - write(fd, magic, 4); + blr_file_add_magic(router,fd); } else { @@ -197,7 +214,7 @@ unsigned char magic[] = BINLOG_MAGIC; close(router->binlog_fd); spinlock_acquire(&router->binlog_lock); strncpy(router->binlog_name, file,BINLOG_FNAMELEN); - router->binlog_position = 4; /* Initial position after the magic number */ + blr_file_add_magic(router, fd); spinlock_release(&router->binlog_lock); router->binlog_fd = fd; return 1; @@ -232,6 +249,18 @@ int fd; spinlock_acquire(&router->binlog_lock); strncpy(router->binlog_name, file,BINLOG_FNAMELEN); router->binlog_position = lseek(fd, 0L, SEEK_END); + if (router->binlog_position < 4) { + if (router->binlog_position == 0) { + blr_file_add_magic(router, fd); + } else { + /* If for any reason the file's length is between 1 and 3 bytes + * then report an error. */ + LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, + "%s: binlog file %s has an invalid length %d.", + router->service->name, path, router->binlog_position))); + return; + } + } spinlock_release(&router->binlog_lock); router->binlog_fd = fd; } From d2adeca583df9857bb2372f91a6adeca4c658e1f Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 28 Apr 2015 11:15:09 +0300 Subject: [PATCH 14/42] Updated MaxScale patch version. --- macros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros.cmake b/macros.cmake index 440c3fed5..8043120d1 100644 --- a/macros.cmake +++ b/macros.cmake @@ -10,7 +10,7 @@ macro(set_maxscale_version) # MaxScale version number set(MAXSCALE_VERSION_MAJOR "1") set(MAXSCALE_VERSION_MINOR "1") - set(MAXSCALE_VERSION_PATCH "0") + set(MAXSCALE_VERSION_PATCH "1") set(MAXSCALE_VERSION_NUMERIC "${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}.${MAXSCALE_VERSION_PATCH}") set(MAXSCALE_VERSION "${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}.${MAXSCALE_VERSION_PATCH}") From 9ef66a6028a76f9b27758656c156e094d78a8551 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 28 Apr 2015 11:23:40 +0300 Subject: [PATCH 15/42] The filter harness no longer builds the MaxScale core twice. --- server/modules/filter/test/CMakeLists.txt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/server/modules/filter/test/CMakeLists.txt b/server/modules/filter/test/CMakeLists.txt index 2ad0c2201..50b5c4e0e 100644 --- a/server/modules/filter/test/CMakeLists.txt +++ b/server/modules/filter/test/CMakeLists.txt @@ -1,13 +1,7 @@ -aux_source_directory(${CMAKE_SOURCE_DIR}/server/core CORE_ALL) -foreach(VAR ${CORE_ALL}) - if(NOT( (${VAR} MATCHES "max[a-z_]*.c") OR (${VAR} MATCHES "gateway.c"))) - list(APPEND CORE ${VAR}) - endif() -endforeach() include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_executable(harness_ui harness_ui.c harness_common.c) -add_executable(harness harness_util.c harness_common.c ${CORE}) +add_executable(harness harness_util.c harness_common.c) 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}) From 3874400abff52ab0b6ebf81add101856fb0039d4 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 28 Apr 2015 11:45:53 +0300 Subject: [PATCH 16/42] Fixed resource leak in blr_file. --- server/modules/routing/binlog/blr_file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/server/modules/routing/binlog/blr_file.c b/server/modules/routing/binlog/blr_file.c index b8e201227..2473909ec 100644 --- a/server/modules/routing/binlog/blr_file.c +++ b/server/modules/routing/binlog/blr_file.c @@ -258,6 +258,7 @@ int fd; LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "%s: binlog file %s has an invalid length %d.", router->service->name, path, router->binlog_position))); + close(fd); return; } } From 74b5e1ddcfd7d64205ca54184b70ef963b6c1974 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 28 Apr 2015 18:31:30 +0300 Subject: [PATCH 17/42] Added fix for MariaDB 10.0 embedded server missing the 5.5.5- string from the server handshake. --- server/core/config.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/core/config.c b/server/core/config.c index a0bc6e3d0..093e8bc35 100644 --- a/server/core/config.c +++ b/server/core/config.c @@ -211,10 +211,18 @@ int rval; if (mysql_real_connect(conn, NULL, NULL, NULL, NULL, 0, NULL, 0)) { char *ptr; version_string = (char *)mysql_get_server_info(conn); + unsigned int server_version = mysql_get_server_version(conn); ptr = strstr(version_string, "-embedded"); if (ptr) { *ptr = '\0'; } + if (server_version >= 100000) + { + char* tmpstr = malloc(strlen(version_string) + strlen("5.5.5-") + 1); + strcpy(tmpstr,"5.5.5-"); + strcat(tmpstr,version_string); + version_string = tmpstr; + } } mysql_close(conn); } From bf7576a501e81df9ce5cd2571ee29f0df7854d1e Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 28 Apr 2015 18:43:40 +0300 Subject: [PATCH 18/42] Fixed memory leak in config_load --- server/core/config.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/server/core/config.c b/server/core/config.c index 093e8bc35..390e3153c 100644 --- a/server/core/config.c +++ b/server/core/config.c @@ -209,20 +209,33 @@ int rval; conn = mysql_init(NULL); if (conn) { if (mysql_real_connect(conn, NULL, NULL, NULL, NULL, 0, NULL, 0)) { - char *ptr; - version_string = (char *)mysql_get_server_info(conn); + char *ptr,*tmp; + + tmp = (char *)mysql_get_server_info(conn); unsigned int server_version = mysql_get_server_version(conn); - ptr = strstr(version_string, "-embedded"); + + if(version_string) + free(version_string); + + if((version_string = malloc(strlen(tmp) + strlen("5.5.5-") + 1)) == NULL) + return 0; + + if (server_version >= 100000) + { + strcpy(version_string,"5.5.5-"); + strcat(version_string,tmp); + } + else + { + strcpy(version_string,tmp); + } + + ptr = strstr(tmp, "-embedded"); if (ptr) { *ptr = '\0'; } - if (server_version >= 100000) - { - char* tmpstr = malloc(strlen(version_string) + strlen("5.5.5-") + 1); - strcpy(tmpstr,"5.5.5-"); - strcat(tmpstr,version_string); - version_string = tmpstr; - } + + } mysql_close(conn); } From 9ce225c2cb57fe27f8a4e177e4b638b554328be6 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 29 Apr 2015 11:20:40 +0300 Subject: [PATCH 19/42] Added log manager initialization flag that prints all logs to stdout. --- log_manager/log_manager.cc | 78 ++++++++++++++---------- server/core/maxkeys.c | 8 +-- server/core/maxpasswd.c | 7 ++- server/modules/filter/dbfwfilter.c | 8 +-- utils/skygw_utils.cc | 96 ++++++++---------------------- utils/skygw_utils.h | 70 ++++++++++++++++++++++ 6 files changed, 152 insertions(+), 115 deletions(-) diff --git a/log_manager/log_manager.cc b/log_manager/log_manager.cc index 05f5044c6..acce7326c 100644 --- a/log_manager/log_manager.cc +++ b/log_manager/log_manager.cc @@ -54,7 +54,7 @@ static simple_mutex_t msg_mutex; static int highprec = 0; static int do_syslog = 1; static int do_maxscalelog = 1; - +static int use_stdout = 0; /** * Variable holding the enabled logfiles information. * Used from log users to check enabled logs prior calling @@ -1331,12 +1331,14 @@ static bool logfile_set_enabled( } lf = &lm->lm_logfile[id]; CHK_LOGFILE(lf); - - if (val) { - logstr = strdup("---\tLogging to file is enabled\t--"); - } else { - logstr = strdup("---\tLogging to file is disabled\t--"); - } + if(use_stdout == 0) + { + if (val) { + logstr = strdup("---\tLogging to file is enabled\t--"); + } else { + logstr = strdup("---\tLogging to file is disabled\t--"); + } + oldval = lf->lf_enabled; lf->lf_enabled = val; err = logmanager_write_log(id, @@ -1348,7 +1350,7 @@ static bool logfile_set_enabled( logstr, notused); free(logstr); - + } if (err != 0) { lf->lf_enabled = oldval; fprintf(stderr, @@ -1445,7 +1447,7 @@ int skygw_log_write( * Find out the length of log string (to be formatted str). */ va_start(valist, str); - len = vsnprintf(NULL, 0, str, valist); + len = vsnprintf(NULL, 0, str, valist); va_end(valist); /** * Add one for line feed. @@ -1695,9 +1697,12 @@ static bool fnames_conf_init( fn->fn_chk_tail = CHK_NUM_FNAMES; #endif optind = 1; /**fn_debug_prefix = strndup(optarg, MAX_PREFIXLEN); break; @@ -2153,8 +2158,14 @@ static bool logfile_open_file( bool succp; char* start_msg_str; int err; - - if (lf->lf_store_shmem) + + if(use_stdout) + { + fw->fwr_file[lf->lf_id] = skygw_file_init_stdout ( + lf->lf_full_file_name, + lf->lf_full_link_name); + } + else if (lf->lf_store_shmem) { /** Create symlink pointing to log file */ fw->fwr_file[lf->lf_id] = skygw_file_init( @@ -2177,32 +2188,35 @@ static bool logfile_open_file( succp = false; goto return_succp; } - - if (lf->lf_enabled) - { + + if(use_stdout == 0) + { + if (lf->lf_enabled) + { start_msg_str = strdup("---\tLogging is enabled.\n"); - } - else - { + } + else + { start_msg_str = strdup("---\tLogging is disabled.\n"); - } - err = skygw_file_write(fw->fwr_file[lf->lf_id], - (void *)start_msg_str, - strlen(start_msg_str), - true); - - if (err != 0) - { + } + err = skygw_file_write(fw->fwr_file[lf->lf_id], + (void *)start_msg_str, + strlen(start_msg_str), + true); + + if (err != 0) + { fprintf(stderr, - "Error : writing to file %s failed due to %d, %s. " + "Error : writing to file %s failed due to %d, %s. " "Exiting MaxScale.\n", - lf->lf_full_file_name, - err, - strerror(err)); + lf->lf_full_file_name, + err, + strerror(err)); succp = false; goto return_succp; - } - free(start_msg_str); + } + free(start_msg_str); + } succp = true; return_succp: diff --git a/server/core/maxkeys.c b/server/core/maxkeys.c index 0d5c938ff..2d245d52c 100644 --- a/server/core/maxkeys.c +++ b/server/core/maxkeys.c @@ -33,7 +33,7 @@ #include int main(int argc, char **argv) { - int arg_count = 3; + int arg_count = 4; char *home; char** arg_vector; @@ -44,7 +44,7 @@ int main(int argc, char **argv) exit(1); } - arg_vector = malloc(sizeof(char*)*4); + arg_vector = malloc(sizeof(char*)*5); if(arg_vector == NULL) { @@ -64,8 +64,8 @@ int main(int argc, char **argv) { arg_vector[2] = strdup("/usr/local/mariadb-maxscale/log"); } - - arg_vector[3] = NULL; + arg_vector[3] = "-o"; + arg_vector[4] = NULL; skygw_logmanager_init(arg_count,arg_vector); skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_DEBUG); diff --git a/server/core/maxpasswd.c b/server/core/maxpasswd.c index 4da1dbde1..d568124f1 100644 --- a/server/core/maxpasswd.c +++ b/server/core/maxpasswd.c @@ -41,7 +41,7 @@ int main(int argc, char **argv) { char *enc, *pw; - int arg_count = 3; + int arg_count = 4; char *home; char** arg_vector; @@ -52,7 +52,7 @@ main(int argc, char **argv) exit(1); } - arg_vector = malloc(sizeof(char*)*4); + arg_vector = malloc(sizeof(char*)*5); if(arg_vector == NULL) { @@ -73,7 +73,8 @@ main(int argc, char **argv) arg_vector[2] = strdup("/usr/local/mariadb-maxscale/log"); } - arg_vector[3] = NULL; + arg_vector[3] = "-o"; + arg_vector[4] = NULL; skygw_logmanager_init(arg_count,arg_vector); skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_DEBUG); diff --git a/server/modules/filter/dbfwfilter.c b/server/modules/filter/dbfwfilter.c index 9cdc2816f..8e756f715 100644 --- a/server/modules/filter/dbfwfilter.c +++ b/server/modules/filter/dbfwfilter.c @@ -2144,15 +2144,11 @@ int main(int argc, char** argv) } printf("Log files written to: %s\n",home?home:"/tpm"); - int argc_ = 11; + int argc_ = 2; char* argv_[] = { "log_manager", - "-j",home?home:"/tmp", - "-a","ruleparser_debug", - "-c","ruleparser_trace", - "-e","ruleparser_message", - "-g","ruleparser_error", + "-o", NULL }; diff --git a/utils/skygw_utils.cc b/utils/skygw_utils.cc index 78a37d43a..101393c1b 100644 --- a/utils/skygw_utils.cc +++ b/utils/skygw_utils.cc @@ -30,76 +30,6 @@ #include #include "skygw_utils.h" -const char* timestamp_formatstr = "%04d-%02d-%02d %02d:%02d:%02d "; -/** One for terminating '\0' */ -const size_t timestamp_len = (4+1 +2+1 +2+1 +2+1 +2+1 +2+3 +1) * sizeof(char); - - -const char* timestamp_formatstr_hp = "%04d-%02d-%02d %02d:%02d:%02d.%03d "; -/** One for terminating '\0' */ -const size_t timestamp_len_hp = (4+1 +2+1 +2+1 +2+1 +2+1 +2+1+3+3 +1) * sizeof(char); - -/** Single-linked list for storing test cases */ - -struct slist_node_st { - skygw_chk_t slnode_chk_top; - slist_t* slnode_list; - slist_node_t* slnode_next; - void* slnode_data; - size_t slnode_cursor_refcount; - skygw_chk_t slnode_chk_tail; -}; - -struct slist_st { - skygw_chk_t slist_chk_top; - slist_node_t* slist_head; - slist_node_t* slist_tail; - int slist_nelems; - slist_t* slist_cursors_list; - skygw_chk_t slist_chk_tail; -}; - -struct slist_cursor_st { - skygw_chk_t slcursor_chk_top; - slist_t* slcursor_list; - slist_node_t* slcursor_pos; - skygw_chk_t slcursor_chk_tail; -}; - -struct skygw_thread_st { - skygw_chk_t sth_chk_top; - bool sth_must_exit; - simple_mutex_t* sth_mutex; - pthread_t sth_parent; - pthread_t sth_thr; - int sth_errno; -#if defined(SS_DEBUG) - skygw_thr_state_t sth_state; -#endif - char* sth_name; - void* (*sth_thrfun)(void* data); - void* sth_data; - skygw_chk_t sth_chk_tail; -}; - -struct skygw_message_st { - skygw_chk_t mes_chk_top; - bool mes_sent; - pthread_mutex_t mes_mutex; - pthread_cond_t mes_cond; - skygw_chk_t mes_chk_tail; -}; - -struct skygw_file_st { - skygw_chk_t sf_chk_top; - char* sf_fname; - FILE* sf_file; - int sf_fd; - skygw_chk_t sf_chk_tail; -}; - -/** End of structs and types */ - #if defined(MLIST) @@ -2033,6 +1963,32 @@ return_file: return file; } + +skygw_file_t* skygw_file_init_stdout( + char* fname, + char* symlinkname) +{ + skygw_file_t* file; + + if ((file = (skygw_file_t *)calloc(1, sizeof(skygw_file_t))) == NULL) + { + fprintf(stderr, + "* Error : Memory allocation for file %s failed.\n", + fname); + perror("SkyGW file allocation\n"); + goto return_file; + } + ss_dassert(file != NULL); + file->sf_chk_top = CHK_NUM_FILE; + file->sf_chk_tail = CHK_NUM_FILE; + file->sf_fname = strdup(fname); + file->sf_file = stdout; + CHK_FILE(file); + +return_file: + return file; +} + void skygw_file_close( skygw_file_t* file, bool shutdown) diff --git a/utils/skygw_utils.h b/utils/skygw_utils.h index ff4055fc7..b4cd3cb45 100644 --- a/utils/skygw_utils.h +++ b/utils/skygw_utils.h @@ -80,6 +80,75 @@ struct mlist_node_st { typedef enum { THR_INIT, THR_RUNNING, THR_STOPPED, THR_DONE } skygw_thr_state_t; typedef enum { MES_RC_FAIL, MES_RC_SUCCESS, MES_RC_TIMEOUT } skygw_mes_rc_t; + +static const char* timestamp_formatstr = "%04d-%02d-%02d %02d:%02d:%02d "; +/** One for terminating '\0' */ +static const size_t timestamp_len = (4+1 +2+1 +2+1 +2+1 +2+1 +2+3 +1) * sizeof(char); + + +static const char* timestamp_formatstr_hp = "%04d-%02d-%02d %02d:%02d:%02d.%03d "; +/** One for terminating '\0' */ +static const size_t timestamp_len_hp = (4+1 +2+1 +2+1 +2+1 +2+1 +2+1+3+3 +1) * sizeof(char); + +/** Single-linked list for storing test cases */ + +struct slist_node_st { + skygw_chk_t slnode_chk_top; + slist_t* slnode_list; + slist_node_t* slnode_next; + void* slnode_data; + size_t slnode_cursor_refcount; + skygw_chk_t slnode_chk_tail; +}; + +struct slist_st { + skygw_chk_t slist_chk_top; + slist_node_t* slist_head; + slist_node_t* slist_tail; + int slist_nelems; + slist_t* slist_cursors_list; + skygw_chk_t slist_chk_tail; +}; + +struct slist_cursor_st { + skygw_chk_t slcursor_chk_top; + slist_t* slcursor_list; + slist_node_t* slcursor_pos; + skygw_chk_t slcursor_chk_tail; +}; + +struct skygw_thread_st { + skygw_chk_t sth_chk_top; + bool sth_must_exit; + simple_mutex_t* sth_mutex; + pthread_t sth_parent; + pthread_t sth_thr; + int sth_errno; +#if defined(SS_DEBUG) + skygw_thr_state_t sth_state; +#endif + char* sth_name; + void* (*sth_thrfun)(void* data); + void* sth_data; + skygw_chk_t sth_chk_tail; +}; + +struct skygw_message_st { + skygw_chk_t mes_chk_top; + bool mes_sent; + pthread_mutex_t mes_mutex; + pthread_cond_t mes_cond; + skygw_chk_t mes_chk_tail; +}; + +struct skygw_file_st { + skygw_chk_t sf_chk_top; + char* sf_fname; + FILE* sf_file; + int sf_fd; + skygw_chk_t sf_chk_tail; +}; + EXTERN_C_BLOCK_BEGIN slist_cursor_t* slist_init(void); @@ -148,6 +217,7 @@ EXTERN_C_BLOCK_END /** Skygw file routines */ skygw_file_t* skygw_file_init(char* fname, char* symlinkname); +skygw_file_t* skygw_file_init_stdout(char* fname, char* symlinkname); void skygw_file_close(skygw_file_t* file, bool shutdown); int skygw_file_write( skygw_file_t* file, From 8bff81e0a9674449c59391d776051a0ee47e3081 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 29 Apr 2015 11:39:17 +0300 Subject: [PATCH 20/42] Fixed rule parsing failing if at_times is used with on_queries. --- server/modules/filter/dbfwfilter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/modules/filter/dbfwfilter.c b/server/modules/filter/dbfwfilter.c index 9cdc2816f..58eedcc4b 100644 --- a/server/modules/filter/dbfwfilter.c +++ b/server/modules/filter/dbfwfilter.c @@ -946,6 +946,8 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) while(tok) { + reparse_rule: + if(strcmp(tok,"wildcard") == 0) { ruledef->type = RT_WILDCARD; @@ -974,7 +976,8 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) tok = strtok_r(NULL, " ,",&saveptr); TIMERANGE *tr = NULL; while(tok){ - + if(strcmp(tok,"on_queries") == 0) + goto reparse_rule; if(!check_time(tok)) { skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, malformed time definition: %s",tok); From 1755706ada87ca7cb44cda97816c3d846a31983f Mon Sep 17 00:00:00 2001 From: MassimilianoPinto Date: Wed, 29 Apr 2015 10:50:21 +0200 Subject: [PATCH 21/42] Master/Slave detection based on variable only Master/Slave role setting is now based on variable value only. Replication is checked and, if working, master_id, slave_id are saved into server struct --- server/modules/monitor/mm_mon.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/server/modules/monitor/mm_mon.c b/server/modules/monitor/mm_mon.c index a71d2cc7d..60acea825 100644 --- a/server/modules/monitor/mm_mon.c +++ b/server/modules/monitor/mm_mon.c @@ -531,18 +531,20 @@ char *server_string; } /* get variable 'read_only' set by an external component */ - if (mysql_query(database->con, "SHOW GLOBAL VARIABLES LIKE 'read_only'") == 0 - && (result = mysql_store_result(database->con)) != NULL) - { - num_fields = mysql_num_fields(result); - while ((row = mysql_fetch_row(result))) - { - if (strncasecmp(row[1], "OFF", 3) == 0) { - ismaster = 1; - } - } - mysql_free_result(result); - } + if (mysql_query(database->con, "SHOW GLOBAL VARIABLES LIKE 'read_only'") == 0 + && (result = mysql_store_result(database->con)) != NULL) + { + num_fields = mysql_num_fields(result); + while ((row = mysql_fetch_row(result))) + { + if (strncasecmp(row[1], "OFF", 3) == 0) { + ismaster = 1; + } else { + isslave = 1; + } + } + mysql_free_result(result); + } /* Remove addition info */ monitor_clear_pending_status(database, SERVER_STALE_STATUS); @@ -563,7 +565,7 @@ char *server_string; } /* Set the Master role */ - if (isslave && ismaster) + if (ismaster) { monitor_clear_pending_status(database, SERVER_SLAVE); monitor_set_pending_status(database, SERVER_MASTER); From c190433c7d31a623d7fc1741757896bbcdc4c0c7 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 29 Apr 2015 14:29:43 +0300 Subject: [PATCH 22/42] Fixed dbfwfilter rules. Fixed at_times not working if combined with on_queries. --- server/modules/filter/dbfwfilter.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/modules/filter/dbfwfilter.c b/server/modules/filter/dbfwfilter.c index 58eedcc4b..372309034 100644 --- a/server/modules/filter/dbfwfilter.c +++ b/server/modules/filter/dbfwfilter.c @@ -977,7 +977,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) TIMERANGE *tr = NULL; while(tok){ if(strcmp(tok,"on_queries") == 0) - goto reparse_rule; + break; if(!check_time(tok)) { skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, malformed time definition: %s",tok); @@ -1003,8 +1003,12 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) tr = tmp; tok = strtok_r(NULL, " ,",&saveptr); } + ruledef->active = tr; + if(strcmp(tok,"on_queries") == 0) + goto reparse_rule; + } else if(strcmp(tok,"regex") == 0) { From 87133388dc8e89f898706e25659ff4db1b972dff Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 29 Apr 2015 15:08:18 +0300 Subject: [PATCH 23/42] Added a note to the dbfwfilter documentation about using local time. --- Documentation/filters/Database-Firewall-Filter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/filters/Database-Firewall-Filter.md b/Documentation/filters/Database-Firewall-Filter.md index cf4db676d..9e76cb1de 100644 --- a/Documentation/filters/Database-Firewall-Filter.md +++ b/Documentation/filters/Database-Firewall-Filter.md @@ -74,7 +74,7 @@ Each mandatory rule accepts one or more optional parameters. These are to be def #### `at_times` -This rule expects a list of time ranges that define the times when the rule in question is active. The time formats are expected to be ISO-8601 compliant and to be separated by a single dash (the - character). For example, to define the active period of a rule to be 5pm to 7pm, you would include `at times 17:00:00-19:00:00` in the rule definition. +This rule expects a list of time ranges that define the times when the rule in question is active. The time formats are expected to be ISO-8601 compliant and to be separated by a single dash (the - character). For example, to define the active period of a rule to be 5pm to 7pm, you would include `at times 17:00:00-19:00:00` in the rule definition. The rule uses local time to check if the rule is active. #### `on_queries` From 47e5b12eb8106b3a8d2a4bc85a54d45a063428ed Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 29 Apr 2015 18:25:04 +0300 Subject: [PATCH 24/42] Added a function that frees the skygw_file_t memory but doesn't close it. --- log_manager/log_manager.cc | 5 ++++- utils/skygw_utils.cc | 28 ++++++++++++++++++++++++++++ utils/skygw_utils.h | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/log_manager/log_manager.cc b/log_manager/log_manager.cc index acce7326c..19d644900 100644 --- a/log_manager/log_manager.cc +++ b/log_manager/log_manager.cc @@ -2741,7 +2741,10 @@ static void filewriter_done( for (i=LOGFILE_FIRST; i<=LOGFILE_LAST; i++) { id = (logfile_id_t)i; - skygw_file_close(fw->fwr_file[id], true); + if(use_stdout) + skygw_file_close_stdout(fw->fwr_file[id], true); + else + skygw_file_close(fw->fwr_file[id], true); } fw->fwr_state = DONE; case DONE: diff --git a/utils/skygw_utils.cc b/utils/skygw_utils.cc index 101393c1b..a2f37fc01 100644 --- a/utils/skygw_utils.cc +++ b/utils/skygw_utils.cc @@ -1989,6 +1989,34 @@ return_file: return file; } + +void skygw_file_close_stdout( + skygw_file_t* file, + bool shutdown) +{ + int fd; + int err; + + if (file != NULL) + { + CHK_FILE(file); + + if (!file_write_footer(file, shutdown)) + { + fprintf(stderr, + "* Writing footer to log file %s failed.\n", + file->sf_fname); + perror("Write fike footer\n"); + } + fd = fileno(file->sf_file); + fsync(fd); + + ss_dfprintf(stderr, "Closed %s\n", file->sf_fname); + free(file->sf_fname); + free(file); + } +} + void skygw_file_close( skygw_file_t* file, bool shutdown) diff --git a/utils/skygw_utils.h b/utils/skygw_utils.h index b4cd3cb45..9370c91cd 100644 --- a/utils/skygw_utils.h +++ b/utils/skygw_utils.h @@ -219,6 +219,7 @@ EXTERN_C_BLOCK_END skygw_file_t* skygw_file_init(char* fname, char* symlinkname); skygw_file_t* skygw_file_init_stdout(char* fname, char* symlinkname); void skygw_file_close(skygw_file_t* file, bool shutdown); +void skygw_file_close_stdout(skygw_file_t*, bool); int skygw_file_write( skygw_file_t* file, void* data, From 00abb3868971450194fc08895bb7251c9802c5d4 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 29 Apr 2015 19:19:36 +0300 Subject: [PATCH 25/42] Fixed rule parsing --- .../filters/Database-Firewall-Filter.md | 2 +- server/modules/filter/dbfwfilter.c | 73 ++++++++++++++++++- 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/Documentation/filters/Database-Firewall-Filter.md b/Documentation/filters/Database-Firewall-Filter.md index 9e76cb1de..b448b65be 100644 --- a/Documentation/filters/Database-Firewall-Filter.md +++ b/Documentation/filters/Database-Firewall-Filter.md @@ -74,7 +74,7 @@ Each mandatory rule accepts one or more optional parameters. These are to be def #### `at_times` -This rule expects a list of time ranges that define the times when the rule in question is active. The time formats are expected to be ISO-8601 compliant and to be separated by a single dash (the - character). For example, to define the active period of a rule to be 5pm to 7pm, you would include `at times 17:00:00-19:00:00` in the rule definition. The rule uses local time to check if the rule is active. +This rule expects a list of time ranges that define the times when the rule in question is active. The time formats are expected to be ISO-8601 compliant and to be separated by a single dash (the - character). For example, to define the active period of a rule to be 5pm to 7pm, you would include `at times 17:00:00-19:00:00` in the rule definition. The rule uses local time to check if the rule is active and has a precision of one second. #### `on_queries` diff --git a/server/modules/filter/dbfwfilter.c b/server/modules/filter/dbfwfilter.c index 372309034..ccf2a2800 100644 --- a/server/modules/filter/dbfwfilter.c +++ b/server/modules/filter/dbfwfilter.c @@ -86,6 +86,14 @@ MODULE_INFO info = { static char *version_str = "V1.0.0"; +static char* required_rules[] = { + "wildcard", + "columns", + "regex", + "limit_queries", + "no_where_clause", + NULL +}; /* * The filter entry points */ @@ -861,6 +869,10 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) bool allow,deny,mode; RULE* ruledef = NULL; bool rval = true; + bool req_defined,oq_def,at_def; + int i; + + req_defined = oq_def = at_def = false; if(tok == NULL) { @@ -920,7 +932,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) } else { - skygw_log_write(LOGFILE_ERROR,"Error : Unknown token in rule file: %s",tok); + skygw_log_write(LOGFILE_ERROR,"Error : Unknown token in rule '%s': %s",rule,tok); rval = false; goto retblock; } @@ -947,6 +959,23 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) while(tok) { reparse_rule: + + for(i = 0;required_rules[i] != NULL;i++) + { + if(strcmp(tok,required_rules[i]) == 0) + { + if(req_defined) + { + skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, Multiple non-optional rules: %s",rule); + rval = false; + goto retblock; + } + else + { + req_defined = true; + } + } + } if(strcmp(tok,"wildcard") == 0) { @@ -972,7 +1001,13 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) } else if(strcmp(tok,"at_times") == 0) { - + if(at_def) + { + skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, multiple 'at_times' tokens: %s",rule); + rval = false; + goto retblock; + } + at_def = true; tok = strtok_r(NULL, " ,",&saveptr); TIMERANGE *tr = NULL; while(tok){ @@ -1126,14 +1161,24 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule parsing failed, not a number: '%s'.", tok); goto retblock; } + + if(qs->limit < 1){ + free(qs); + rval = false; + skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Bad query amount: %s", tok); + goto retblock; + } + errptr = NULL; tok = strtok_r(NULL," ",&saveptr); + if(tok == NULL){ free(qs); rval = false; skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Missing parameter in limit_queries: '%s'.", rule); goto retblock; } + qs->period = strtod(tok,&errptr); if(errptr && *errptr != '\0') @@ -1143,9 +1188,17 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Rule parsing failed, not a number: '%s'.", tok); goto retblock; } - errptr = NULL; + if(qs->period < 1){ + free(qs); + rval = false; + skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Bad time period: %s", tok); + goto retblock; + } + + errptr = NULL; tok = strtok_r(NULL," ",&saveptr); + if(tok == NULL){ free(qs); rval = false; @@ -1162,6 +1215,13 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) goto retblock; } + if(qs->cooldown < 1){ + free(qs); + rval = false; + skygw_log_write(LOGFILE_ERROR, "dbfwfilter: Bad blocking period: %s", tok); + goto retblock; + } + ruledef->type = RT_THROTTLE; ruledef->data = (void*)qs; } @@ -1172,6 +1232,13 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) } else if(strcmp(tok,"on_queries") == 0) { + if(oq_def) + { + skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, multiple 'on_queries' tokens: %s",rule); + rval = false; + goto retblock; + } + oq_def = true; tok = strtok_r(NULL," ",&saveptr); if(tok == NULL) From 7c988c4fd52c8b6919f03285c6837b409f5cdbd9 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 30 Apr 2015 04:26:48 +0300 Subject: [PATCH 26/42] Removed stdout specific functions in skygw_utils and moved the logic to log_manager instead. --- log_manager/log_manager.cc | 11 +++-- utils/skygw_utils.cc | 90 ++++++++++++-------------------------- utils/skygw_utils.h | 4 +- 3 files changed, 36 insertions(+), 69 deletions(-) diff --git a/log_manager/log_manager.cc b/log_manager/log_manager.cc index 19d644900..9358a9f97 100644 --- a/log_manager/log_manager.cc +++ b/log_manager/log_manager.cc @@ -2161,9 +2161,9 @@ static bool logfile_open_file( if(use_stdout) { - fw->fwr_file[lf->lf_id] = skygw_file_init_stdout ( - lf->lf_full_file_name, - lf->lf_full_link_name); + fw->fwr_file[lf->lf_id] = skygw_file_alloc ( + lf->lf_full_file_name); + fw->fwr_file[lf->lf_id]->sf_file = stdout; } else if (lf->lf_store_shmem) { @@ -2742,7 +2742,7 @@ static void filewriter_done( { id = (logfile_id_t)i; if(use_stdout) - skygw_file_close_stdout(fw->fwr_file[id], true); + skygw_file_free(fw->fwr_file[id]); else skygw_file_close(fw->fwr_file[id], true); } @@ -2876,6 +2876,9 @@ static void* thr_filewriter_fun( } else if ((succp = logfile_open_file(fwr, lf))) { + if(use_stdout) + skygw_file_free (file); + else skygw_file_close(file, false); /*< close old file */ } diff --git a/utils/skygw_utils.cc b/utils/skygw_utils.cc index a2f37fc01..4ebcada2d 100644 --- a/utils/skygw_utils.cc +++ b/utils/skygw_utils.cc @@ -1882,24 +1882,37 @@ return_rc: return rc; } +skygw_file_t* skygw_file_alloc( + char* fname) +{ + skygw_file_t* file; + + if ((file = (skygw_file_t *)calloc(1, sizeof(skygw_file_t))) == NULL) + { + fprintf(stderr, + "* Error : Memory allocation for file %s failed.\n", + fname); + perror("SkyGW file allocation\n"); + return NULL; + } + ss_dassert(file != NULL); + file->sf_chk_top = CHK_NUM_FILE; + file->sf_chk_tail = CHK_NUM_FILE; + file->sf_fname = strdup(fname); + return file; +} + skygw_file_t* skygw_file_init( char* fname, char* symlinkname) { skygw_file_t* file; - if ((file = (skygw_file_t *)calloc(1, sizeof(skygw_file_t))) == NULL) + if ((file = skygw_file_alloc (fname)) == NULL) { - fprintf(stderr, - "* Error : Memory allocation for file %s failed.\n", - fname); - perror("SkyGW file allocation\n"); + /** Error was reported in skygw_file_alloc */ goto return_file; } - ss_dassert(file != NULL); - file->sf_chk_top = CHK_NUM_FILE; - file->sf_chk_tail = CHK_NUM_FILE; - file->sf_fname = strdup(fname); if ((file->sf_file = fopen(file->sf_fname, "a")) == NULL) { @@ -1963,58 +1976,10 @@ return_file: return file; } - -skygw_file_t* skygw_file_init_stdout( - char* fname, - char* symlinkname) +void skygw_file_free(skygw_file_t* file) { - skygw_file_t* file; - - if ((file = (skygw_file_t *)calloc(1, sizeof(skygw_file_t))) == NULL) - { - fprintf(stderr, - "* Error : Memory allocation for file %s failed.\n", - fname); - perror("SkyGW file allocation\n"); - goto return_file; - } - ss_dassert(file != NULL); - file->sf_chk_top = CHK_NUM_FILE; - file->sf_chk_tail = CHK_NUM_FILE; - file->sf_fname = strdup(fname); - file->sf_file = stdout; - CHK_FILE(file); - -return_file: - return file; -} - - -void skygw_file_close_stdout( - skygw_file_t* file, - bool shutdown) -{ - int fd; - int err; - - if (file != NULL) - { - CHK_FILE(file); - - if (!file_write_footer(file, shutdown)) - { - fprintf(stderr, - "* Writing footer to log file %s failed.\n", - file->sf_fname); - perror("Write fike footer\n"); - } - fd = fileno(file->sf_file); - fsync(fd); - - ss_dfprintf(stderr, "Closed %s\n", file->sf_fname); - free(file->sf_fname); - free(file); - } + free(file->sf_fname); + free(file); } void skygw_file_close( @@ -2037,7 +2002,7 @@ void skygw_file_close( } fd = fileno(file->sf_file); fsync(fd); - + if ((err = fclose(file->sf_file)) != 0) { fprintf(stderr, @@ -2049,8 +2014,7 @@ void skygw_file_close( else { ss_dfprintf(stderr, "Closed %s\n", file->sf_fname); - free(file->sf_fname); - free(file); + skygw_file_free (file); } } } diff --git a/utils/skygw_utils.h b/utils/skygw_utils.h index 9370c91cd..b2022cc54 100644 --- a/utils/skygw_utils.h +++ b/utils/skygw_utils.h @@ -216,10 +216,10 @@ EXTERN_C_BLOCK_END /** Skygw thread routines */ /** Skygw file routines */ +skygw_file_t* skygw_file_alloc(char* fname); +void skygw_file_free(skygw_file_t* file); skygw_file_t* skygw_file_init(char* fname, char* symlinkname); -skygw_file_t* skygw_file_init_stdout(char* fname, char* symlinkname); void skygw_file_close(skygw_file_t* file, bool shutdown); -void skygw_file_close_stdout(skygw_file_t*, bool); int skygw_file_write( skygw_file_t* file, void* data, From 6e4aa9862d76ed52627a5d7d1d176cd3c036c9c2 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 30 Apr 2015 04:52:35 +0300 Subject: [PATCH 27/42] Fixed a segfaul caused by a null pointer in dbfwfilter rule parsing. --- server/modules/filter/dbfwfilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/modules/filter/dbfwfilter.c b/server/modules/filter/dbfwfilter.c index ccf2a2800..255eb6aba 100644 --- a/server/modules/filter/dbfwfilter.c +++ b/server/modules/filter/dbfwfilter.c @@ -1041,7 +1041,7 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) ruledef->active = tr; - if(strcmp(tok,"on_queries") == 0) + if(tok && strcmp(tok,"on_queries") == 0) goto reparse_rule; } From 360db8b235924e134cb7108dc4f979f9b63139fb Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 30 Apr 2015 10:58:35 +0300 Subject: [PATCH 28/42] Changed all atoi calls to config_truth_value when they were used to generate boolean values. --- server/core/config.c | 14 +++++++------- server/modules/filter/qlafilter.c | 2 +- server/modules/filter/slavelag.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/server/core/config.c b/server/core/config.c index 390e3153c..764a606c8 100644 --- a/server/core/config.c +++ b/server/core/config.c @@ -1308,7 +1308,7 @@ int i; } else if (strcmp(name, "ms_timestamp") == 0) { - skygw_set_highp(atoi(value)); + skygw_set_highp(config_truth_value(value)); } else { @@ -1316,7 +1316,7 @@ int i; { if (strcasecmp(name, lognames[i].logname) == 0) { - if (atoi(value)) + if (config_truth_value(value)) skygw_log_enable(lognames[i].logfile); else skygw_log_disable(lognames[i].logfile); @@ -1495,10 +1495,10 @@ SERVER *server; user, auth); if (enable_root_user) - serviceEnableRootUser(service, atoi(enable_root_user)); + serviceEnableRootUser(service, config_truth_value(enable_root_user)); if (connection_timeout) - serviceSetTimeout(service, atoi(connection_timeout)); + serviceSetTimeout(service, config_truth_value(connection_timeout)); if(auth_all_servers) @@ -1511,7 +1511,7 @@ SERVER *server; if (allow_localhost_match_wildcard_host) serviceEnableLocalhostMatchWildcardHost( service, - atoi(allow_localhost_match_wildcard_host)); + config_truth_value(allow_localhost_match_wildcard_host)); /** Read, validate and set max_slave_connections */ max_slave_conn_str = @@ -1651,7 +1651,7 @@ SERVER *server; user, auth); if (enable_root_user) - serviceEnableRootUser(obj->element, atoi(enable_root_user)); + serviceEnableRootUser(obj->element, config_truth_value(enable_root_user)); if (connection_timeout) serviceSetTimeout(obj->element, atoi(connection_timeout)); @@ -1659,7 +1659,7 @@ SERVER *server; if (allow_localhost_match_wildcard_host) serviceEnableLocalhostMatchWildcardHost( obj->element, - atoi(allow_localhost_match_wildcard_host)); + config_truth_value(allow_localhost_match_wildcard_host)); } } } diff --git a/server/modules/filter/qlafilter.c b/server/modules/filter/qlafilter.c index c9af0a839..5362cf61e 100644 --- a/server/modules/filter/qlafilter.c +++ b/server/modules/filter/qlafilter.c @@ -95,7 +95,7 @@ static FILTER_OBJECT MyObject = { * are logged. * * To this base a session number is attached such that each session will - * have a nique name. + * have a unique name. */ typedef struct { int sessions; /* The count of sessions */ diff --git a/server/modules/filter/slavelag.c b/server/modules/filter/slavelag.c index c12d7a2a7..eb6b9536d 100644 --- a/server/modules/filter/slavelag.c +++ b/server/modules/filter/slavelag.c @@ -41,10 +41,10 @@ extern __thread log_info_t tls_log_info; * Two optional parameters that define the behavior after a data modifying query * is executed: * - * count= Queries to route to master after data modification. - * time=