diff --git a/README b/README index a939021d0..920c24994 100644 --- a/README +++ b/README @@ -29,7 +29,7 @@ issues and communicate with the MaxScale community. or use the [forum](http://groups.google.com/forum/#!forum/maxscale) interface Bugs can be reported in the MariaDB Corporation bugs database - [bug.skysql.com](http://bugs.skysql.com) + [bug.mariadb.com](http://bugs.mariadb.com) \section Building Building MaxScale diff --git a/debian/changelog b/debian/changelog index e416d995a..846f67a10 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,9 +2,9 @@ maxscale (1.0-beta) UNRELEASED; urgency=low * Beta release - -- Timofey Turenko Fri, 05 Jul 2014 14:00:00 +0200 + -- Timofey Turenko Fri, 05 Jul 2014 14:00:00 +0200 maxscale (0.7-1) UNRELEASED; urgency=low * Initial release. (Closes: #XXXXXX) - -- Timofey Turenko Tue, 11 Mar 2014 22:59:35 +0200 + -- Timofey Turenko Tue, 11 Mar 2014 22:59:35 +0200 diff --git a/log_manager/log_manager.cc b/log_manager/log_manager.cc index 59e108920..f9aeb57d3 100644 --- a/log_manager/log_manager.cc +++ b/log_manager/log_manager.cc @@ -270,12 +270,14 @@ static void blockbuf_register(blockbuf_t* bb); static void blockbuf_unregister(blockbuf_t* bb); static bool logfile_set_enabled(logfile_id_t id, bool val); static char* add_slash(char* str); -static bool file_exists_and_is_writable(char* filename, bool* writable); + +static bool check_file_and_path( + char* filename, + bool* nameconflict, + bool* writable); + static bool file_is_symlink(char* filename); - - - const char* get_suffix_default(void) { return ".log"; @@ -356,11 +358,6 @@ static bool logmanager_init_nomutex( fw = &lm->lm_filewriter; fn->fn_state = UNINIT; fw->fwr_state = UNINIT; - - /** - * Set global variable - */ - lm_enabled_logfiles_bitmask = lm->lm_enabled_logfiles; /** Initialize configuration including log file naming info */ if (!fnames_conf_init(fn, argc, argv)) { @@ -368,14 +365,23 @@ static bool logmanager_init_nomutex( } /** Initialize logfiles */ - if(!logfiles_init(lm)) { - goto return_succp; + if(!logfiles_init(lm)) + { + err = 1; + goto return_succp; } - /** Initialize filewriter data and open the (first) log file(s) + /** + * Set global variable + */ + lm_enabled_logfiles_bitmask = lm->lm_enabled_logfiles; + + /** Initialize filewriter data and open the (first) log file(s) * for each log file type. */ - if (!filewriter_init(lm, fw, lm->lm_clientmes, lm->lm_logmes)) { - goto return_succp; + if (!filewriter_init(lm, fw, lm->lm_clientmes, lm->lm_logmes)) + { + err = 1; + goto return_succp; } /** Initialize and start filewriter thread */ @@ -383,8 +389,9 @@ static bool logmanager_init_nomutex( thr_filewriter_fun, (void *)fw); - if ((err = skygw_thread_start(fw->fwr_thread)) != 0) { - goto return_succp; + if ((err = skygw_thread_start(fw->fwr_thread)) != 0) + { + goto return_succp; } /** Wait message from filewriter_thr */ skygw_message_wait(fw->fwr_clientmes); @@ -393,10 +400,11 @@ static bool logmanager_init_nomutex( lm->lm_enabled = true; return_succp: - if (err != 0) { + if (err != 0) + { /** This releases memory of all created objects */ logmanager_done_nomutex(); - fprintf(stderr, "* Initializing logmanager failed.\n"); + fprintf(stderr, "*\n* Error : Initializing log manager failed.\n*\n"); } return succp; } @@ -1769,7 +1777,7 @@ static bool logfiles_init( write_syslog); if (!succp) { - fprintf(stderr, "Initializing logfiles failed\n"); + fprintf(stderr, "*\n* Error : Initializing log files failed.\n"); break; } lid <<= 1; @@ -1917,10 +1925,11 @@ static char* add_slash( return str; } -/** - * @node Check if the file exists in the local file system and if it does, - * whether it is writable. - * + +/** + * @node Check if the path and file exist in the local file system and if they do, + * check if they are accessible and writable. + * * Parameters: * @param filename - * @@ -1928,55 +1937,91 @@ static char* add_slash( * @param writable - * * - * @return + * @return true & writable if file exists and it is writable, + * true & not writable if file exists but it can't be written, + * false & writable if file doesn't exist but directory could be written, and + * false & not writable if directory can't be written. * - * - * @details Note, that an space character is written to the end of file. + * @details Note, that a space character is written to the end of file. * TODO: recall what was the reason for not succeeding with simply * calling access, and fstat. vraa 26.11.13 - * */ -static bool file_exists_and_is_writable( - char* filename, - bool* writable) +static bool check_file_and_path( + char* filename, + bool* writable) { - int fd; - bool exists = true; - - if (filename == NULL) - { - exists = false; - } - else - { - fd = open(filename, O_CREAT|O_EXCL, S_IRWXU); - - /** file exist */ - if (fd == -1) - { - /** Open file and write a byte for test */ - fd = open(filename, O_CREAT|O_RDWR, S_IRWXU|S_IRWXG); - - if (fd != -1) - { - char c = ' '; - if (write(fd, &c, 1) == 1) - { - *writable = true; - } - close(fd); - } - } - else - { - close(fd); - unlink(filename); - exists = false; - } - } - return exists; + int fd; + bool exists; + + if (filename == NULL) + { + exists = false; + *writable = false; + } + 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) + { + fprintf(stderr, + "*\n* Error : Can't access %s due " + "to %s.\n", + filename, + strerror(errno)); + *writable = false; + } + else + { + char c = ' '; + if (write(fd, &c, 1) == 1) + { + *writable = true; + } + else + { + fprintf(stderr, + "*\n* Error : Can't write to " + "%s due to %s.\n", + filename, + strerror(errno)); + *writable = false; + } + close(fd); + } + exists = true; + } + else + { + fprintf(stderr, + "*\n* Error : Can't access %s due to %s.\n", + filename, + strerror(errno)); + exists = false; + *writable = false; + } + } + else + { + close(fd); + unlink(filename); + exists = false; + *writable = true; + } + } + return exists; } + + static bool file_is_symlink( char* filename) { @@ -2112,7 +2157,8 @@ static bool logfile_init( logfile->lf_full_file_name = form_full_file_name(strparts, logfile->lf_name_seqno, 2); - if (store_shmem) { + if (store_shmem) + { strparts[0].sp_string = logfile->lf_linkpath; /** * Create name for link file @@ -2121,17 +2167,7 @@ static bool logfile_init( form_full_file_name(strparts, logfile->lf_name_seqno, 2); - fprintf(stderr, "%s\t: %s->%s\n", - STRLOGNAME(logfile_id), - logfile->lf_full_link_name, - logfile->lf_full_file_name); } - else - { - fprintf(stderr, "%s\t: %s\n", - STRLOGNAME(logfile_id), - logfile->lf_full_file_name); - } /** * At least one of the files couldn't be created. Increase * sequence number and retry until succeeds. @@ -2147,32 +2183,57 @@ static bool logfile_init( * If file exists but is different type, create fails and * new, increased sequence number is added to file name. */ - if (file_exists_and_is_writable(logfile->lf_full_file_name, - &writable)) - { - if (!writable || - file_is_symlink(logfile->lf_full_file_name)) - { - nameconflicts = true; - goto file_create_fail; - } - } - - if (store_shmem) - { - writable = false; + if (check_file_and_path( + logfile->lf_full_file_name, + &writable)) + { + /** Found similarly named file which isn't writable */ + if (!writable || + file_is_symlink(logfile->lf_full_file_name)) + { + nameconflicts = true; + goto file_create_fail; + } + } + else + { + /** + * Opening the file failed for some other reason than + * existing non-writable file. Shut down. + */ + if (!writable) + { + succp = false; + goto return_with_succp; + } + } - if (file_exists_and_is_writable( - logfile->lf_full_link_name, - &writable)) - { - if (!writable || - !file_is_symlink(logfile->lf_full_link_name)) - { - nameconflicts = true; - goto file_create_fail; - } - } + if (store_shmem) + { + if (check_file_and_path( + logfile->lf_full_file_name, + &writable)) + { + /** Found similarly named file which isn't writable */ + if (!writable || + file_is_symlink(logfile->lf_full_file_name)) + { + nameconflicts = true; + goto file_create_fail; + } + } + else + { + /** + * Opening the file failed for some other reason than + * existing non-writable file. Shut down. + */ + if (!writable) + { + succp = false; + goto return_with_succp; + } + } } file_create_fail: if (namecreatefail || nameconflicts) @@ -2189,7 +2250,6 @@ file_create_fail: free(logfile->lf_full_link_name); logfile->lf_full_link_name = NULL; } - goto return_with_succp; } } while (namecreatefail || nameconflicts); /** @@ -2203,11 +2263,24 @@ file_create_fail: MAXNBLOCKBUFS) == NULL) { ss_dfprintf(stderr, - "Initializing logfile blockbuf list " - "failed\n"); + "*\n* Error : Initializing buffers for log files " + "failed."); logfile_free_memory(logfile); goto return_with_succp; } + if (store_shmem) + { + fprintf(stderr, "%s\t: %s->%s\n", + STRLOGNAME(logfile_id), + logfile->lf_full_link_name, + logfile->lf_full_file_name); + } + else + { + fprintf(stderr, "%s\t: %s\n", + STRLOGNAME(logfile_id), + logfile->lf_full_file_name); + } succp = true; logfile->lf_state = RUN; CHK_LOGFILE(logfile); @@ -2245,12 +2318,18 @@ static void logfile_done( { switch(lf->lf_state) { case RUN: - CHK_LOGFILE(lf); - ss_dassert(lf->lf_npending_writes == 0); + CHK_LOGFILE(lf); + ss_dassert(lf->lf_npending_writes == 0); + /** fallthrough */ case INIT: - mlist_done(&lf->lf_blockbuf_list); - logfile_free_memory(lf); - lf->lf_state = DONE; + /** Test if list is initialized before freeing it */ + if (lf->lf_blockbuf_list.mlist_versno != 0) + { + mlist_done(&lf->lf_blockbuf_list); + } + logfile_free_memory(lf); + lf->lf_state = DONE; + /** fallthrough */ case DONE: case UNINIT: default: diff --git a/macros.cmake b/macros.cmake index 920c915c7..3b75fcfa6 100644 --- a/macros.cmake +++ b/macros.cmake @@ -1,9 +1,15 @@ +function(debugmsg MSG) + if(DEBUG_OUTPUT) + message(STATUS "DEBUG: ${MSG}") + endif() +endfunction() + macro(set_maxscale_version) #MaxScale version number set(MAXSCALE_VERSION_MAJOR "1") set(MAXSCALE_VERSION_MINOR "0") - set(MAXSCALE_VERSION_PATCH "1") + set(MAXSCALE_VERSION_PATCH "2") 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}-beta") @@ -85,17 +91,13 @@ macro(check_dirs) # Find the MySQL headers if they were not defined if(DEFINED MYSQL_DIR) - if(DEBUG_OUTPUT) - message(STATUS "Searching for MySQL headers at: ${MYSQL_DIR}") - endif() + debugmsg("Searching for MySQL headers at: ${MYSQL_DIR}") find_path(MYSQL_DIR_LOC mysql.h PATHS ${MYSQL_DIR} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH) else() find_path(MYSQL_DIR_LOC mysql.h PATH_SUFFIXES mysql mariadb) endif() - - if(DEBUG_OUTPUT) - message(STATUS "Search returned: ${MYSQL_DIR_LOC}") - endif() + +debugmsg("Search returned: ${MYSQL_DIR_LOC}") if(${MYSQL_DIR_LOC} MATCHES "NOTFOUND") set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.") @@ -109,6 +111,7 @@ macro(check_dirs) # Find the errmsg.sys file if it was not defied if( DEFINED ERRMSG ) + debugmsg("Looking for errmsg.sys at: ${ERRMSG}") find_file(ERRMSG_FILE errmsg.sys PATHS ${ERRMSG} NO_DEFAULT_PATH) endif() find_file(ERRMSG_FILE errmsg.sys PATHS /usr/share/mysql /usr/local/share/mysql PATH_SUFFIXES english) @@ -122,42 +125,52 @@ macro(check_dirs) unset(ERRMSG_FILE) # Find the embedded mysql library - if(STATIC_EMBEDDED) + + if (DEFINED EMBEDDED_LIB) + debugmsg("Searching for the embedded library at: ${EMBEDDED_LIB}") + if(${CMAKE_VERSION} VERSION_LESS 2.12 ) + set(COMP_VAR PATH) + else() + set(COMP_VAR DIRECTORY) + endif() + get_filename_component(EMBEDDED_LIB ${EMBEDDED_LIB} ${COMP_VAR}) + endif() + if(STATIC_EMBEDDED) + + debugmsg("Using the static embedded library...") set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") if (DEFINED EMBEDDED_LIB) - if(DEBUG_OUTPUT) - message(STATUS "Searching for libmysqld.a at: ${EMBEDDED_LIB}") - endif() + debugmsg("Searching for libmysqld.a at: ${EMBEDDED_LIB}") find_library(EMBEDDED_LIB_STATIC libmysqld.a PATHS ${EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH) else() find_library(EMBEDDED_LIB_STATIC libmysqld.a PATH_SUFFIXES mysql mariadb) endif() - if(DEBUG_OUTPUT) - message(STATUS "Search returned: ${EMBEDDED_LIB_STATIC}") - endif() + debugmsg("Search returned: ${EMBEDDED_LIB_STATIC}") + set(EMBEDDED_LIB ${EMBEDDED_LIB_STATIC} CACHE FILEPATH "Path to libmysqld" FORCE) set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES}) - unset(OLD_SUFFIXES) - else() + else() + debugmsg("Using the dynamic embedded library...") + set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".so") if (DEFINED EMBEDDED_LIB) - if(DEBUG_OUTPUT) - message(STATUS "Searching for libmysqld.so at: ${EMBEDDED_LIB}") - endif() + debugmsg("Searching for libmysqld.so at: ${EMBEDDED_LIB}") find_library(EMBEDDED_LIB_DYNAMIC mysqld PATHS ${EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH) else() find_library(EMBEDDED_LIB_DYNAMIC mysqld PATH_SUFFIXES mysql mariadb) endif() - if(DEBUG_OUTPUT) - message(STATUS "Search returned: ${EMBEDDED_LIB_DYNAMIC}") - endif() + debugmsg("Search returned: ${EMBEDDED_LIB_DYNAMIC}") set(EMBEDDED_LIB ${EMBEDDED_LIB_DYNAMIC} CACHE FILEPATH "Path to libmysqld" FORCE) - + set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES}) + endif() + unset(EMBEDDED_LIB_DYNAMIC) unset(EMBEDDED_LIB_STATIC) + unset(OLD_SUFFIXES) # Inform the user about the embedded library if( (${EMBEDDED_LIB} MATCHES "NOTFOUND") OR (${EMBEDDED_LIB} MATCHES "NOTFOUND")) @@ -238,4 +251,4 @@ endif() endforeach() list(REMOVE_DUPLICATES ALLDIRS) set(${VAR} "${ALLDIRS}" CACHE PATH " " FORCE) -endfunction() \ No newline at end of file +endfunction() diff --git a/replication_listener/access_method_factory.cpp b/replication_listener/access_method_factory.cpp index 7261b9355..b44f69692 100644 --- a/replication_listener/access_method_factory.cpp +++ b/replication_listener/access_method_factory.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA MariaDB Corporation change details: - Removed unnecessary file driver -Author: Jan Lindström (jan.lindstrom@skysql.com +Author: Jan Lindström (jan.lindstrom@mariadb.com */ #include "access_method_factory.h" diff --git a/replication_listener/basic_content_handler.cpp b/replication_listener/basic_content_handler.cpp index 9b209ab28..ffcc35fde 100644 --- a/replication_listener/basic_content_handler.cpp +++ b/replication_listener/basic_content_handler.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA MariaDB Corporation change details: - Added GTID event handler -Author: Jan Lindström (jan.lindstrom@skysql.com +Author: Jan Lindström (jan.lindstrom@mariadb.com */ diff --git a/replication_listener/basic_content_handler.h b/replication_listener/basic_content_handler.h index 5debfb672..7a83838af 100644 --- a/replication_listener/basic_content_handler.h +++ b/replication_listener/basic_content_handler.h @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA MariaDB Corporation change details: - Added GTID event handler -Author: Jan Lindström (jan.lindstrom@skysql.com +Author: Jan Lindström (jan.lindstrom@mariadb.com */ diff --git a/replication_listener/binary_log.cpp b/replication_listener/binary_log.cpp index 199cf65c4..20c87c896 100644 --- a/replication_listener/binary_log.cpp +++ b/replication_listener/binary_log.cpp @@ -27,7 +27,7 @@ MariaDB Corporation change details: - Added support for setting binlog position based on GTID - Added support for MySQL and MariDB server types -Author: Jan Lindström (jan.lindstrom@skysql.com +Author: Jan Lindström (jan.lindstrom@mariadb.com */ diff --git a/replication_listener/binlog_api.h b/replication_listener/binlog_api.h index fb6e24f77..33d32fd1d 100644 --- a/replication_listener/binlog_api.h +++ b/replication_listener/binlog_api.h @@ -27,7 +27,7 @@ MariaDB Corporation change details: - Added support for setting binlog position based on GTID - Added support for MySQL and MariDB server types -Author: Jan Lindström (jan.lindstrom@skysql.com +Author: Jan Lindström (jan.lindstrom@mariadb.com */ diff --git a/replication_listener/binlog_driver.cpp b/replication_listener/binlog_driver.cpp index 86c3ea954..81c019332 100644 --- a/replication_listener/binlog_driver.cpp +++ b/replication_listener/binlog_driver.cpp @@ -26,7 +26,7 @@ MariaDB Corporation change details: - Added support for GTID event handling for both MySQL and MariaDB -Author: Jan Lindström (jan.lindstrom@skysql.com +Author: Jan Lindström (jan.lindstrom@mariadb.com */ diff --git a/replication_listener/binlog_driver.h b/replication_listener/binlog_driver.h index 73e60587d..44f9fb3c4 100644 --- a/replication_listener/binlog_driver.h +++ b/replication_listener/binlog_driver.h @@ -27,7 +27,7 @@ MariaDB Corporation change details: - Added support for GTID event handling for both MySQL and MariaDB - Added support for setting binlog position based on GTID -Author: Jan Lindström (jan.lindstrom@skysql.com +Author: Jan Lindström (jan.lindstrom@mariadb.com */ diff --git a/replication_listener/binlog_event.cpp b/replication_listener/binlog_event.cpp index d1f4da802..d89142333 100644 --- a/replication_listener/binlog_event.cpp +++ b/replication_listener/binlog_event.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA MariaDB Corporation change details: - Added support for GTID event handling for both MySQL and MariaDB -Author: Jan Lindström (jan.lindstrom@skysql.com +Author: Jan Lindström (jan.lindstrom@mariadb.com */ diff --git a/replication_listener/binlog_event.h b/replication_listener/binlog_event.h index 3c8285044..45aa31a83 100644 --- a/replication_listener/binlog_event.h +++ b/replication_listener/binlog_event.h @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA MariaDB Corporation change details: - Added support for GTID event handling for both MySQL and MariaDB -Author: Jan Lindström (jan.lindstrom@skysql.com +Author: Jan Lindström (jan.lindstrom@mariadb.com */ #ifndef _BINLOG_EVENT_H diff --git a/replication_listener/gtid.cpp b/replication_listener/gtid.cpp index ed9d80bea..7091dfc92 100644 --- a/replication_listener/gtid.cpp +++ b/replication_listener/gtid.cpp @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -Author: Jan Lindström jan.lindstrom@skysql.com +Author: Jan Lindström jan.lindstrom@mariadb.com */ diff --git a/replication_listener/gtid.h b/replication_listener/gtid.h index 359ae9d04..218e2a30f 100644 --- a/replication_listener/gtid.h +++ b/replication_listener/gtid.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -Author: Jan Lindström jan.lindstrom@skysql.com +Author: Jan Lindström jan.lindstrom@mariadb.com */ diff --git a/replication_listener/listener_exception.h b/replication_listener/listener_exception.h index 7ff656ea8..b38312b58 100644 --- a/replication_listener/listener_exception.h +++ b/replication_listener/listener_exception.h @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -Author: Jan Lindström jan.lindstrom@skysql.com +Author: Jan Lindström jan.lindstrom@mariadb.com */ diff --git a/replication_listener/protocol.cpp b/replication_listener/protocol.cpp index 8d07f6877..317500ce8 100644 --- a/replication_listener/protocol.cpp +++ b/replication_listener/protocol.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA MariaDB Corporation change details: - Added support for GTID event handling for both MySQL and MariaDB -Author: Jan Lindström (jan.lindstrom@skysql.com +Author: Jan Lindström (jan.lindstrom@mariadb.com */ #include diff --git a/replication_listener/tcp_driver.cpp b/replication_listener/tcp_driver.cpp index 216077249..a0aa88986 100644 --- a/replication_listener/tcp_driver.cpp +++ b/replication_listener/tcp_driver.cpp @@ -28,7 +28,7 @@ MariaDB Corporation change details: - Added support for starting binlog dump from GTID position - Added error handling using exceptions -Author: Jan Lindström (jan.lindstrom@skysql.com +Author: Jan Lindström (jan.lindstrom@mariadb.com */ #include "binlog_api.h" diff --git a/replication_listener/tcp_driver.h b/replication_listener/tcp_driver.h index 7d4d96c94..530249276 100644 --- a/replication_listener/tcp_driver.h +++ b/replication_listener/tcp_driver.h @@ -28,7 +28,7 @@ MariaDB Corporation change details: - Added support for starting binlog dump from GTID position - Added support for MariaDB server -Author: Jan Lindström (jan.lindstrom@skysql.com +Author: Jan Lindström (jan.lindstrom@mariadb.com */ diff --git a/replication_listener/tests/event_dump.cpp b/replication_listener/tests/event_dump.cpp index d9c415374..132ba6f8b 100644 --- a/replication_listener/tests/event_dump.cpp +++ b/replication_listener/tests/event_dump.cpp @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -Author: Jan Lindström jan.lindstrom@skysql.com +Author: Jan Lindström jan.lindstrom@mariadb.com */ diff --git a/server/core/gateway.c b/server/core/gateway.c index 8e6dbb5ee..4131366a4 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -73,7 +73,9 @@ #include /** for procname */ -#define _GNU_SOURCE +#if !defined(_GNU_SOURCE) +# define _GNU_SOURCE +#endif extern char *program_invocation_name; extern char *program_invocation_short_name; @@ -174,6 +176,9 @@ static bool resolve_maxscale_conf_fname( char* cnf_file_arg); static bool resolve_maxscale_homedir( char** p_home_dir); + +static char* check_dir_access(char* dirname); + /** * Handler for SIGHUP signal. Reload the configuration for the * gateway. @@ -593,65 +598,45 @@ static bool resolve_maxscale_homedir( if (*p_home_dir != NULL) { log_context = strdup("Current working directory"); - goto check_home_dir; } check_home_dir: - if (*p_home_dir != NULL) - { - if (!file_is_readable(*p_home_dir)) - { - char* tailstr = "MaxScale doesn't have read permission " - "to MAXSCALE_HOME."; - char* logstr = (char*)malloc(strlen(log_context)+ - 1+ - strlen(tailstr)+ - 1); - snprintf(logstr, - strlen(log_context)+ - 1+ - strlen(tailstr)+1, - "%s:%s", - log_context, - tailstr); - print_log_n_stderr(true, true, logstr, logstr, 0); - free(logstr); - goto return_succp; - } - - if (!file_is_writable(*p_home_dir)) - { - char* tailstr = "MaxScale doesn't have write permission " - "to MAXSCALE_HOME. Exiting."; - char* logstr = (char*)malloc(strlen(log_context)+ - 1+ - strlen(tailstr)+ - 1); - snprintf(logstr, - strlen(log_context)+ - 1+ - strlen(tailstr)+1, - "%s:%s", - log_context, - tailstr); - print_log_n_stderr(true, true, logstr, logstr, 0); - free(logstr); - goto return_succp; - } - - if (!daemon_mode) - { - fprintf(stderr, - "Using %s as MAXSCALE_HOME = %s\n", - log_context, - tmp); - } - succp = true; - goto return_succp; - } - -return_succp: - free (tmp); + + if (*p_home_dir != NULL) + { + char* errstr; + + errstr = check_dir_access(*p_home_dir); + + if (errstr != NULL) + { + char* logstr = (char*)malloc(strlen(log_context)+ + 1+ + strlen(errstr)+ + 1); + + snprintf(logstr, + strlen(log_context)+ + 1+ + strlen(errstr)+1, + "%s: %s", + log_context, + errstr); + + print_log_n_stderr(true, true, logstr, logstr, 0); + + free(errstr); + free(logstr); + } + else if (!daemon_mode) + { + fprintf(stderr, + "Using %s as MAXSCALE_HOME = %s\n", + log_context, + tmp); + } + } + free (tmp); if (log_context != NULL) { @@ -668,6 +653,42 @@ return_succp: return succp; } +/** + * Check read and write accessibility to a directory. + * @param dirname directory to be checked + * + * @return NULL if directory can be read and written, an error message if either + * read or write is not permitted. + */ +static char* check_dir_access( + char* dirname) +{ + char* errstr = NULL; + + if (dirname == NULL) + { + errstr = strdup("Directory argument is NULL"); + goto retblock; + } + + if (!file_is_readable(dirname)) + { + errstr = strdup("MaxScale doesn't have read permission " + "to MAXSCALE_HOME."); + goto retblock; + } + + if (!file_is_writable(dirname)) + { + errstr = strdup("MaxScale doesn't have write permission " + "to MAXSCALE_HOME. Exiting."); + goto retblock; + } + +retblock: + return errstr; +} + /** * @node Provides error printing for non-formatted error strings. @@ -1378,6 +1399,44 @@ int main(int argc, char **argv) sprintf(mysql_home, "%s/mysql", home_dir); setenv("MYSQL_HOME", mysql_home, 1); } + else + { + char* log_context = strdup("Home directory command-line argument"); + char* errstr; + + errstr = check_dir_access(home_dir); + + if (errstr != NULL) + { + char* logstr = (char*)malloc(strlen(log_context)+ + 1+ + strlen(errstr)+ + 1); + + snprintf(logstr, + strlen(log_context)+ + 1+ + strlen(errstr)+1, + "%s: %s", + log_context, + errstr); + + print_log_n_stderr(true, true, logstr, logstr, 0); + + free(errstr); + free(logstr); + rc = MAXSCALE_HOMELESS; + goto return_main; + } + else if (!daemon_mode) + { + fprintf(stderr, + "Using %s as MAXSCALE_HOME = %s\n", + log_context, + home_dir); + } + free(log_context); + } /*< * Init Log Manager for MaxScale. @@ -1387,8 +1446,9 @@ int main(int argc, char **argv) * argv[0] */ { - char buf[1024]; - char *argv[8]; + char buf[1024]; + char *argv[8]; + bool succp; sprintf(buf, "%s/log", home_dir); mkdir(buf, 0777); @@ -1401,7 +1461,7 @@ int main(int argc, char **argv) argv[4] = "LOGFILE_MESSAGE,LOGFILE_ERROR" "LOGFILE_DEBUG,LOGFILE_TRACE"; argv[5] = NULL; - skygw_logmanager_init(5, argv); + succp = skygw_logmanager_init(5, argv); } else { @@ -1410,7 +1470,13 @@ int main(int argc, char **argv) argv[5] = "-l"; /*< write to syslog */ argv[6] = "LOGFILE_MESSAGE,LOGFILE_ERROR"; /*< ..these logs to syslog */ argv[7] = NULL; - skygw_logmanager_init(7, argv); + succp = skygw_logmanager_init(7, argv); + } + + if (!succp) + { + rc = MAXSCALE_BADCONFIG; + goto return_main; } } diff --git a/server/core/test/testbuffer.c b/server/core/test/testbuffer.c index 87ebf858b..ee8507161 100644 --- a/server/core/test/testbuffer.c +++ b/server/core/test/testbuffer.c @@ -13,7 +13,7 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright SkySQL Ab 2014 + * Copyright MariaDB Corporation Ab 2014 */ /** @@ -32,6 +32,7 @@ #include #include +#include /** * test1 Allocate a buffer and do lots of things @@ -41,6 +42,7 @@ static int test1() { GWBUF *buffer, *extra, *clone, *partclone, *transform; +HINT *hint; int size = 100; int bite1 = 35; int bite2 = 60; @@ -58,6 +60,10 @@ int buflen; ss_info_dassert(size == buflen, "Incorrect buffer size"); ss_info_dassert(0 == GWBUF_EMPTY(buffer), "Buffer should not be empty"); ss_info_dassert(GWBUF_IS_TYPE_UNDEFINED(buffer), "Buffer type should be undefined"); + ss_dfprintf(stderr, "\t..done\nSet a hint for the buffer"); + hint = hint_create_parameter(NULL, strdup("name"), "value"); + gwbuf_add_hint(buffer, hint); + ss_info_dassert(hint == buffer->hint, "Buffer should point to first and only hint"); ss_dfprintf(stderr, "\t..done\nSet a property for the buffer"); gwbuf_add_property(buffer, "name", "value"); ss_info_dassert(0 == strcmp("value", gwbuf_get_property(buffer, "name")), "Should now have correct property"); diff --git a/server/core/test/testdcb.c b/server/core/test/testdcb.c index 5f8e18601..2703763f0 100644 --- a/server/core/test/testdcb.c +++ b/server/core/test/testdcb.c @@ -13,7 +13,7 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright SkySQL Ab 2014 + * Copyright MariaDB Corporation Ab 2014 */ /** @@ -51,6 +51,7 @@ int buflen; ss_dfprintf(stderr, "testdcb : creating buffer with type DCB_ROLE_SERVICE_LISTENER"); dcb = dcb_alloc(DCB_ROLE_SERVICE_LISTENER); + printDCB(dcb); ss_info_dassert(dcb_isvalid(dcb), "New DCB must be valid"); ss_dfprintf(stderr, "\t..done\nAllocated dcb."); clone = dcb_clone(dcb); diff --git a/server/core/test/testgwbitmask.c b/server/core/test/testgwbitmask.c new file mode 100644 index 000000000..86bad1245 --- /dev/null +++ b/server/core/test/testgwbitmask.c @@ -0,0 +1,83 @@ +/* + * This file is distributed as part of MaxScale. It is free + * software: you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation, + * version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright MariaDB Corporation Ab 2014 + */ + +/** + * + * @verbatim + * Revision History + * + * Date Who Description + * 13-10-2014 Martin Brampton Initial implementation + * + * @endverbatim + */ + +#include +#include +#include + +#include + +#include + +/** + * test1 Allocate table of users and mess around with it + * + */ + +static int +test1() +{ +static GWBITMASK bitmask, another; +int i; + + /* Hint tests */ + ss_dfprintf(stderr, + "testgwbitmask : Initialise a bitmask"); + bitmask_init(&bitmask); + ss_info_dassert(BIT_LENGTH_INITIAL == bitmask.length, "Length should be initial length."); + for (i = 0; i < BIT_LENGTH_INITIAL; i++) { + ss_info_dassert(0 == bitmask_isset(&bitmask, i), "All bits should initially be zero"); + } + ss_info_dassert(0 != bitmask_isallclear(&bitmask), "Should be all clear"); + ss_dfprintf(stderr, "\t..done\nSet an arbitrary bit."); + bitmask_set(&bitmask, 17); + bitmask_copy(&another, &bitmask); + ss_info_dassert(0 != bitmask_isset(&another, 17), "Test bit should be set"); + ss_dfprintf(stderr, "\t..done\nClear the arbitrary bit."); + bitmask_clear(&bitmask, 17); + ss_info_dassert(0 == bitmask_isset(&bitmask, 17), "Test bit should be clear"); + ss_info_dassert(0 != bitmask_isallclear(&bitmask), "Should be all clear"); + ss_dfprintf(stderr, "\t..done\nFree the bitmask."); + bitmask_free(&bitmask); + ss_info_dassert(0 == bitmask.length, "Length should be zero after bit mask freed."); + ss_dfprintf(stderr, "\t..done\n"); + + return 0; + +} + +int main(int argc, char **argv) +{ +int result = 0; + + result += test1(); + + exit(result); +} + diff --git a/server/core/test/testhint.c b/server/core/test/testhint.c index 3d2241642..b615baced 100644 --- a/server/core/test/testhint.c +++ b/server/core/test/testhint.c @@ -13,7 +13,7 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright SkySQL Ab 2014 + * Copyright MariaDB Corporation Ab 2014 */ /** diff --git a/server/core/test/testmodutil.c b/server/core/test/testmodutil.c index e83facdc5..b37203ff4 100644 --- a/server/core/test/testmodutil.c +++ b/server/core/test/testmodutil.c @@ -13,7 +13,7 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright SkySQL Ab 2014 + * Copyright MariaDB Corporation Ab 2014 */ /** diff --git a/server/core/test/testpoll.c b/server/core/test/testpoll.c index aee799bb4..4d8d4cc04 100644 --- a/server/core/test/testpoll.c +++ b/server/core/test/testpoll.c @@ -13,7 +13,7 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright SkySQL Ab 2014 + * Copyright MariaDB Corporation Ab 2014 */ /** diff --git a/server/core/test/testserver.c b/server/core/test/testserver.c index 56a69e65d..3b05188ab 100644 --- a/server/core/test/testserver.c +++ b/server/core/test/testserver.c @@ -13,7 +13,7 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright SkySQL Ab 2014 + * Copyright MariaDB Corporation Ab 2014 */ /** diff --git a/server/core/test/testservice.c b/server/core/test/testservice.c index 2b12c8062..579bd617f 100644 --- a/server/core/test/testservice.c +++ b/server/core/test/testservice.c @@ -13,7 +13,7 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright SkySQL Ab 2014 + * Copyright MariaDB Corporation Ab 2014 */ /** diff --git a/server/core/test/testusers.c b/server/core/test/testusers.c index f407b273a..3f13cad9b 100644 --- a/server/core/test/testusers.c +++ b/server/core/test/testusers.c @@ -13,7 +13,7 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright SkySQL Ab 2014 + * Copyright MariaDB Corporation Ab 2014 */ /** diff --git a/server/modules/filter/test/Makefile b/server/modules/filter/test/Makefile old mode 100755 new mode 100644 index 5eb6561f7..12546291d --- a/server/modules/filter/test/Makefile +++ b/server/modules/filter/test/Makefile @@ -1,4 +1,4 @@ -# This file is distributed as part of MaxScale form SkySQL. It is free +# This file is distributed as part of MaxScale form MariaDB Corporation. It is free # software: you can redistribute it and/or modify it under the terms of the # GNU General Public License as published by the Free Software Foundation, # version 2. @@ -12,7 +12,7 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # -# Copyright SkySQL Ab 2014 +# Copyright MariaDB Corporation Ab 2014 include ../../../../build_gateway.inc diff --git a/table_replication_consistency/table_replication_consistency.cpp b/table_replication_consistency/table_replication_consistency.cpp index e29fc0cd7..0ef68aa27 100644 --- a/table_replication_consistency/table_replication_consistency.cpp +++ b/table_replication_consistency/table_replication_consistency.cpp @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -Author: Jan Lindström jan.lindstrom@skysql.com +Author: Jan Lindström jan.lindstrom@mariadb.com Created: 20-06-2013 Updated: diff --git a/table_replication_consistency/table_replication_consistency.h b/table_replication_consistency/table_replication_consistency.h index f900d1bf0..10d4451b6 100644 --- a/table_replication_consistency/table_replication_consistency.h +++ b/table_replication_consistency/table_replication_consistency.h @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -Author: Jan Lindström jan.lindstrom@skysql.com +Author: Jan Lindström jan.lindstrom@mariadb.com Created: 20-06-2013 Updated: diff --git a/table_replication_consistency/table_replication_listener.cpp b/table_replication_consistency/table_replication_listener.cpp index 283b49984..6c1502d70 100644 --- a/table_replication_consistency/table_replication_listener.cpp +++ b/table_replication_consistency/table_replication_listener.cpp @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -Author: Jan Lindström jan.lindstrom@skysql.com +Author: Jan Lindström jan.lindstrom@mariadb.com Created: 20-06-2013 Updated: */ diff --git a/table_replication_consistency/table_replication_listener.h b/table_replication_consistency/table_replication_listener.h index 2c1b31794..6cea875f4 100644 --- a/table_replication_consistency/table_replication_listener.h +++ b/table_replication_consistency/table_replication_listener.h @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -Author: Jan Lindström jan.lindstrom@skysql.com +Author: Jan Lindström jan.lindstrom@mariadb.com Created: 20-06-2013 Updated: diff --git a/table_replication_consistency/table_replication_metadata.cpp b/table_replication_consistency/table_replication_metadata.cpp index b25a350ed..0c9a4161f 100644 --- a/table_replication_consistency/table_replication_metadata.cpp +++ b/table_replication_consistency/table_replication_metadata.cpp @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -Author: Jan Lindström jan.lindstrom@skysql.com +Author: Jan Lindström jan.lindstrom@mariadb.com Created: 15-07-2013 Updated: */ diff --git a/table_replication_consistency/table_replication_metadata.h b/table_replication_consistency/table_replication_metadata.h index 910d63295..d29b5b9b1 100644 --- a/table_replication_consistency/table_replication_metadata.h +++ b/table_replication_consistency/table_replication_metadata.h @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -Author: Jan Lindström jan.lindstrom@skysql.com +Author: Jan Lindström jan.lindstrom@mariadb.com Created: 15-07-2013 Updated: */ diff --git a/table_replication_consistency/table_replication_parser.cpp b/table_replication_consistency/table_replication_parser.cpp index 999a9b083..42c92efaf 100644 --- a/table_replication_consistency/table_replication_parser.cpp +++ b/table_replication_consistency/table_replication_parser.cpp @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -Author: Jan Lindström jan.lindstrom@skysql.com +Author: Jan Lindström jan.lindstrom@mariadb.com Created: 20-06-2013 Updated: diff --git a/table_replication_consistency/table_replication_parser.h b/table_replication_consistency/table_replication_parser.h index 5a854e2f7..e60ad8576 100644 --- a/table_replication_consistency/table_replication_parser.h +++ b/table_replication_consistency/table_replication_parser.h @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -Author: Jan Lindström jan.lindstrom@skysql.com +Author: Jan Lindström jan.lindstrom@mariadb.com Created: 20-06-2013 Updated: diff --git a/utils/skygw_utils.cc b/utils/skygw_utils.cc index 3699791c3..4a020d38e 100644 --- a/utils/skygw_utils.cc +++ b/utils/skygw_utils.cc @@ -320,6 +320,7 @@ mlist_t* mlist_init( list->mlist_nodecount_max = maxnodes; /** Set data deletion callback fun */ list->mlist_datadel = datadel; + if (name != NULL) { list->mlist_name = name; } @@ -345,6 +346,7 @@ mlist_t* mlist_init( CHK_MLIST_CURSOR(c); *cursor = c; } + list->mlist_versno = 2; /*< vresno != 0 means that list is initialized */ CHK_MLIST(list); return_list: diff --git a/utils/skygw_utils.h b/utils/skygw_utils.h index 309b9019f..6d2bc7b67 100644 --- a/utils/skygw_utils.h +++ b/utils/skygw_utils.h @@ -52,9 +52,7 @@ typedef struct mlist_st { bool mlist_deleted; size_t mlist_nodecount; size_t mlist_nodecount_max; /**< size limit. 0 == no limit */ -#if 1 size_t mlist_versno; -#endif bool mlist_flat; mlist_node_t* mlist_first; mlist_node_t* mlist_last;