Merge branch 'develop' into query_classifier_test
Conflicts: README macros.cmake
This commit is contained in:
commit
3b0e3d04dc
@ -8,38 +8,45 @@ set_maxscale_version()
|
||||
|
||||
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "Prefix prepended to install directories." FORCE)
|
||||
|
||||
if(NOT ( BUILD_TYPE STREQUAL "None" ) )
|
||||
set(CMAKE_BUILD_TYPE "${BUILD_TYPE}" CACHE INTERNAL "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel. " FORCE)
|
||||
else()
|
||||
set(CMAKE_BUILD_TYPE "")
|
||||
endif()
|
||||
|
||||
project(MaxScale)
|
||||
|
||||
if(NOT DEPS_OK)
|
||||
check_deps()
|
||||
else()
|
||||
message(STATUS "Dependencies ok")
|
||||
endif()
|
||||
|
||||
check_deps()
|
||||
check_dirs()
|
||||
|
||||
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/modules)
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/server/include/version.h.in ${CMAKE_SOURCE_DIR}/server/include/version.h)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/maxscale.conf.in ${CMAKE_SOURCE_DIR}/maxscale.conf @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/init.d/maxscale.in ${CMAKE_SOURCE_DIR}/etc/init.d/maxscale @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/ubuntu/init.d/maxscale.in ${CMAKE_SOURCE_DIR}/etc/ubuntu/init.d/maxscale @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/maxscale.conf.in ${CMAKE_SOURCE_DIR}/maxscale.conf.prep @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/init.d/maxscale.in ${CMAKE_SOURCE_DIR}/etc/init.d/maxscale.prep @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/ubuntu/init.d/maxscale.in ${CMAKE_SOURCE_DIR}/etc/ubuntu/init.d/maxscale.prep @ONLY)
|
||||
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC")
|
||||
set(CMAKE_C_FLAGS "-Wall -fPIC")
|
||||
set(CMAKE_CXX_FLAGS "-Wall -fPIC")
|
||||
|
||||
if(BUILD_TYPE MATCHES Debug)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb -O0 -pthread -pipe -DSS_DEBUG -Wformat -Werror=format-security -fstack-protector --param=ssp-buffer-size=4")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -O0 -pthread -pipe -DSS_DEBUG -Wformat -Werror=format-security -fstack-protector --param=ssp-buffer-size=4")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb -pthread -pipe -DSS_DEBUG -Wformat -Werror=format-security -fstack-protector --param=ssp-buffer-size=4")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -pthread -pipe -DSS_DEBUG -Wformat -Werror=format-security -fstack-protector --param=ssp-buffer-size=4")
|
||||
message(STATUS "Generating debugging symbols")
|
||||
elseif(BUILD_TYPE MATCHES Optimized)
|
||||
if(NOT (DEFINED OLEVEL))
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
message(STATUS "Optimization level at: 2")
|
||||
endif()
|
||||
else()
|
||||
|
||||
endif()
|
||||
|
||||
if(DEFINED OLEVEL )
|
||||
if((OLEVEL GREATER -1) AND (OLEVEL LESS 4) )
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O${OLEVEL}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O${OLEVEL}")
|
||||
message(STATUS "Optimization level at: ${OLEVEL}")
|
||||
else()
|
||||
message(WARNING "Optimization level was set to a bad value, ignoring it. (Valid values are 0-3)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(GCOV)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
@ -48,9 +55,11 @@ if(GCOV)
|
||||
endif()
|
||||
|
||||
|
||||
include_directories(${MYSQL_DIR})
|
||||
include_directories(${MYSQL_DIR}/private)
|
||||
include_directories(${MYSQL_DIR}/extra)
|
||||
subdirs(MYSQL_DIR_ALL ${MYSQL_DIR})
|
||||
foreach(DIR ${MYSQL_DIR_ALL})
|
||||
include_directories(${DIR})
|
||||
endforeach()
|
||||
|
||||
include_directories(${MYSQL_DIR}/..)
|
||||
include_directories(utils)
|
||||
include_directories(log_manager)
|
||||
@ -59,47 +68,34 @@ include_directories(server/include)
|
||||
include_directories(server/inih)
|
||||
include_directories(server/modules/include)
|
||||
|
||||
if(BUILD_RABBITMQ)
|
||||
|
||||
find_path(RABBITMQ_HEADERS amqp.h DOC "Path to the librabbitmq-c headers.")
|
||||
find_library(RABBITMQ_LIB rabbitmq DOC "Path to the librabbitmq-c libraries.")
|
||||
if(RABBITMQ_HEADERS AND RABBITMQ_LIB)
|
||||
message(STATUS "Building RabbitMQ components")
|
||||
include_directories(${RABBITMQ_HEADERS})
|
||||
link_directories(${RABBITMQ_LIB})
|
||||
add_subdirectory(rabbitmq_consumer)
|
||||
else()
|
||||
message(ERROR "Error: Cannot find the librabbitmq-c headers or libraries.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
add_subdirectory(utils)
|
||||
add_subdirectory(log_manager)
|
||||
add_subdirectory(query_classifier)
|
||||
add_subdirectory(server)
|
||||
add_subdirectory(client)
|
||||
|
||||
file(GLOB DOCS Documentation/*.pdf)
|
||||
|
||||
#
|
||||
# Install startup scripts and ldconfig files
|
||||
if( NOT ( (DEFINED INSTALL_SYSTEM_FILES) AND ( NOT ( INSTALL_SYSTEM_FILES ) ) ) )
|
||||
install(FILES maxscale.conf DESTINATION /etc/ld.so.conf.d/ PERMISSIONS WORLD_EXECUTE WORLD_READ)
|
||||
|
||||
install(FILES maxscale.conf.prep RENAME maxscale.conf DESTINATION /etc/ld.so.conf.d/ PERMISSIONS WORLD_EXECUTE WORLD_READ)
|
||||
if(DEB_BASED)
|
||||
install(FILES etc/ubuntu/init.d/maxscale DESTINATION /etc/init.d/ PERMISSIONS WORLD_EXECUTE)
|
||||
install(FILES etc/ubuntu/init.d/maxscale.prep RENAME maxscale DESTINATION /etc/init.d/ PERMISSIONS WORLD_EXECUTE)
|
||||
else()
|
||||
install(FILES etc/init.d/maxscale DESTINATION /etc/init.d/ PERMISSIONS WORLD_EXECUTE)
|
||||
install(FILES etc/init.d/maxscale.prep RENAME maxscale DESTINATION /etc/init.d/ PERMISSIONS WORLD_EXECUTE)
|
||||
endif()
|
||||
message(STATUS "Installing maxscale.conf to: /etc/ld.so.conf.d")
|
||||
message(STATUS "Installing startup scripts to: /etc/init.d")
|
||||
endif()
|
||||
|
||||
file(GLOB DOCS Documentation/*.pdf)
|
||||
message(STATUS "Installing MaxScale to: ${CMAKE_INSTALL_PREFIX}/")
|
||||
|
||||
install(FILES server/MaxScale_template.cnf DESTINATION etc)
|
||||
install(FILES ${ERRMSG} DESTINATION mysql)
|
||||
install(FILES ${DOCS} DESTINATION Documentation)
|
||||
|
||||
#See if we are on a RPM-capable or DEB-capable system
|
||||
# See if we are on a RPM-capable or DEB-capable system
|
||||
find_program(RPMBUILD rpmbuild)
|
||||
find_program(DEBBUILD dpkg-buildpackage)
|
||||
|
||||
@ -119,15 +115,15 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MaxScale")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${MAXSCALE_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${MAXSCALE_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${MAXSCALE_VERSION_PATCH}")
|
||||
set(CPACK_PACKAGE_CONTACT "SkySQL Ab")
|
||||
set(CPACK_PACKAGE_CONTACT "MariaDB Corporation Ab")
|
||||
set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}")
|
||||
set(CPACK_PACKAGE_NAME "maxscale")
|
||||
set(CPACK_PACKAGE_VENDOR "SkySQL Ab")
|
||||
set(CPACK_PACKAGE_VENDOR "MariaDB Corporation Ab")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/README)
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
set(CPACK_RPM_SPEC_INSTALL_POST "/sbin/ldconfig")
|
||||
set(CPACK_RPM_PACKAGE_NAME "maxscale")
|
||||
set(CPACK_RPM_PACKAGE_VENDOR "SkySQL Ab")
|
||||
set(CPACK_RPM_PACKAGE_VENDOR "MariaDB Corporation Ab")
|
||||
set(CPACK_RPM_PACKAGE_LICENSE "GPLv2")
|
||||
set(CPACK_RPM_PACKAGE_AUTOREQPROV " no")
|
||||
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/etc /etc/ld.so.conf.d /etc/init.d /etc/rc.d/init.d")
|
||||
@ -139,5 +135,7 @@ include(CPack)
|
||||
add_custom_target(testall
|
||||
COMMAND ${CMAKE_COMMAND} -DDEPS_OK=Y -DBUILD_TESTS=Y -DBUILD_TYPE=Debug -DINSTALL_DIR=${CMAKE_BINARY_DIR} -DINSTALL_SYSTEM_FILES=N ${CMAKE_SOURCE_DIR}
|
||||
COMMAND make install
|
||||
COMMAND make test
|
||||
COMMENT "Running full test suite")
|
||||
COMMAND /bin/sh -c "${CMAKE_BINARY_DIR}/bin/maxscale -c ${CMAKE_BINARY_DIR} &>/dev/null"
|
||||
COMMAND /bin/sh -c "make test || echo \"Test results written to: ${CMAKE_BINARY_DIR}/Testing/Temporary/\""
|
||||
COMMAND killall maxscale
|
||||
COMMENT "Running full test suite" VERBATIM)
|
@ -1,4 +1,4 @@
|
||||
This source code is distributed as part of SkySQL MaxScale. It is free
|
||||
This source code is distributed as part of MariaDB Corporation 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.
|
||||
@ -12,9 +12,9 @@ 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 SkySQL Ab 2013
|
||||
Copyright MariaDB Corporation Ab 2013
|
||||
|
||||
SkySQL Corporation Ab
|
||||
MariaDB Corporation Corporation Ab
|
||||
Tekniikantie 12
|
||||
02150 Espoo
|
||||
Finland
|
||||
|
BIN
Documentation/MaxScale 1.0.1beta Release Notes.pdf
Normal file
BIN
Documentation/MaxScale 1.0.1beta Release Notes.pdf
Normal file
Binary file not shown.
6
Makefile
6
Makefile
@ -1,4 +1,4 @@
|
||||
# This file is distributed as part of the SkySQL Gateway. It is free
|
||||
# This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
# Copyright MariaDB Corporation Ab 2013
|
||||
#
|
||||
# Revision History
|
||||
# Date Who Description
|
||||
@ -57,7 +57,7 @@ depend:
|
||||
install:
|
||||
(cd server; make DEST=$(DEST) install)
|
||||
(cd log_manager; make DEST=$(DEST) install)
|
||||
(cd query_classifier; make DEST=$(DEST) install)
|
||||
(cd query_classifier;touch depend; make DEST=$(DEST) install)
|
||||
(cd client; make DEST=$(DEST) install)
|
||||
|
||||
cleantests:
|
||||
|
29
README
29
README
@ -1,6 +1,6 @@
|
||||
/** \mainpage MaxScale by SkySQL
|
||||
/** \mainpage MaxScale by MariaDB Corporation
|
||||
|
||||
The SkySQL MaxScale is an intelligent proxy that allows forwarding of
|
||||
The MariaDB Corporation MaxScale is an intelligent proxy that allows forwarding of
|
||||
database statements to one or more database servers using complex rules,
|
||||
a semantic understanding of the database statements and the roles of
|
||||
the various servers within the backend cluster of databases.
|
||||
@ -28,7 +28,7 @@ issues and communicate with the MaxScale community.
|
||||
Send email to [maxscale@googlegroups.com](mailto:maxscale@googlegroups.com)
|
||||
or use the [forum](http://groups.google.com/forum/#!forum/maxscale) interface
|
||||
|
||||
Bugs can be reported in the SkySQL bugs database
|
||||
Bugs can be reported in the MariaDB Corporation bugs database
|
||||
[bug.skysql.com](http://bugs.skysql.com)
|
||||
|
||||
\section Building Building MaxScale
|
||||
@ -59,6 +59,10 @@ to the --relocate option.
|
||||
|
||||
rpm -i --force --relocate=/usr/=$PREFIX/usr/ MariaDB-5.5.34-centos6-x86_64-common.rpm MariaDB-5.5.34-centos6-x86_64-compat.rpm MariaDB-5.5.34-centos6-x86_64-devel.rpm
|
||||
|
||||
You can also use the included 'unpack_rpm.sh' script to unpack the RPMs without installing them.
|
||||
|
||||
./unpack_rpm <location of MariaDB RPMs> <extraction destination>
|
||||
|
||||
This README assumes $PREFIX = $HOME.
|
||||
|
||||
MaxScale may be built with the embedded MariaDB library either linked
|
||||
@ -164,7 +168,7 @@ explicitly state the locations you can pass additional options to CMake by using
|
||||
values, you can run CMake in interactive mode by using the -i flag or use a CMake GUI (for example, ccmake for command line).
|
||||
|
||||
It is highly recommended to make a separate build directory to build into. This keeps the source and build trees clean and
|
||||
makes it easy to get rid of everything you built.
|
||||
makes it easy to get rid of everything you built by simply deleting the build directory.
|
||||
|
||||
To build MaxScale using CMake:
|
||||
|
||||
@ -172,7 +176,7 @@ To build MaxScale using CMake:
|
||||
|
||||
mkdir build
|
||||
|
||||
cd build
|
||||
cd build
|
||||
|
||||
cmake ..
|
||||
|
||||
@ -183,11 +187,6 @@ To build MaxScale using CMake:
|
||||
This generates the required makefiles in the current directory, compiles and links all the programs and installs
|
||||
all the required files in their right places.
|
||||
|
||||
To build MaxScale using the ccmake GUI:
|
||||
|
||||
ccmake <path to MaxScale source>
|
||||
|
||||
|
||||
If you have your headers and libraries in non-standard locations, you can define those locations at configuration time as such:
|
||||
|
||||
cmake -D<variable>=<value>
|
||||
@ -198,20 +197,22 @@ variable to your desired installation directory and set INSTALL_SYSTEM_FILES=N t
|
||||
If you run into any trouble while configuring CMake, you can always remove the 'CMakeCache.txt' file to clear CMake's
|
||||
internal cache. This resets all values to their defaults and can be used to fix a 'stuck' configuration of CMake. This
|
||||
is also a good reason why you should always build into a separate directory, because you can safely wipe the build directory clean without the
|
||||
danger of deleting important files.
|
||||
danger of deleting important files when something goes wrong.
|
||||
|
||||
All the parameters affecting CMake can be found in 'macros.cmake'. This file also has the parameters CMake uses for testing.
|
||||
The default values that CMake uses can be found in the 'macros.cmake' file. If you wish to change these, edit the 'macros.cmake' file
|
||||
or define the variables manually at configuration time.
|
||||
|
||||
All the variables that control the CMake build process:
|
||||
|
||||
INSTALL_DIR=<path> Installation directory
|
||||
BUILD_TYPE=[None|Debug|Release] Type of the build, defaults to Release (optimized)
|
||||
INSTALL_SYSTEM_FILES=[Y|N] Install startup scripts and ld configuration files
|
||||
EMBEDDED_LIB=<path> Path to the embedded library, filename included
|
||||
EMBEDDED_LIB=<path> Path to the embedded library location (libmysqld.a for static and libmysqld.so for dynamic)
|
||||
MYSQL_DIR=<path> Path to MySQL headers
|
||||
ERRMSG=<path> Path to errmsg.sys file
|
||||
STATIC_EMBEDDED=[Y|N] Link the static or the dynamic verson of the library
|
||||
STATIC_EMBEDDED=[Y|N] Whether to link the static or the dynamic verson of the library
|
||||
GCOV=[Y|N] Generate gcov output
|
||||
OLEVEL=<0-3> Level of optimization
|
||||
BUILD_TESTS=[Y|N] Build tests
|
||||
DEPS_OK=[Y|N] Check dependencies, use N when you want to force a recheck of values
|
||||
DEBUG_OUTPUT=[Y|N] Produce debugging output when configuring CMake
|
||||
|
@ -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
|
||||
#
|
||||
# Revision History
|
||||
# Date Who Description
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -273,7 +273,10 @@ char c;
|
||||
}
|
||||
else if (*buf)
|
||||
{
|
||||
sendCommand(so, buf);
|
||||
if (!sendCommand(so, buf))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,6 +301,7 @@ connectMaxScale(char *hostname, char *port)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
int so;
|
||||
int keepalive = 1;
|
||||
|
||||
if ((so = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
@ -315,6 +319,9 @@ int so;
|
||||
hostname, port, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (setsockopt(so, SOL_SOCKET,
|
||||
SO_KEEPALIVE, &keepalive , sizeof(keepalive )))
|
||||
perror("setsockopt");
|
||||
|
||||
return so;
|
||||
}
|
||||
@ -387,11 +394,14 @@ authMaxScale(int so, char *user, char *password)
|
||||
{
|
||||
char buf[20];
|
||||
|
||||
read(so, buf, 4);
|
||||
if (read(so, buf, 4) != 4)
|
||||
return 0;
|
||||
write(so, user, strlen(user));
|
||||
read(so, buf, 8);
|
||||
if (read(so, buf, 8) != 8)
|
||||
return 0;
|
||||
write(so, password, strlen(password));
|
||||
read(so, buf, 6);
|
||||
if (read(so, buf, 6) != 6)
|
||||
return 0;
|
||||
|
||||
return strncmp(buf, "FAILED", 6);
|
||||
}
|
||||
@ -412,10 +422,11 @@ sendCommand(int so, char *cmd)
|
||||
char buf[80];
|
||||
int i, j, newline = 1;
|
||||
|
||||
write(so, cmd, strlen(cmd));
|
||||
if (write(so, cmd, strlen(cmd)) == -1)
|
||||
return 0;
|
||||
while (1)
|
||||
{
|
||||
if ((i = read(so, buf, 80)) == -1)
|
||||
if ((i = read(so, buf, 80)) <= 0)
|
||||
return 0;
|
||||
for (j = 0; j < i; j++)
|
||||
{
|
||||
|
53
client/test/maxadmin_stress.sh
Normal file
53
client/test/maxadmin_stress.sh
Normal file
@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
failure=0
|
||||
passed=0
|
||||
|
||||
clients=20
|
||||
cmdcnt=1000
|
||||
|
||||
echo Running $clients parallel iterations of $cmdcnt commands
|
||||
|
||||
for ((cnt=0; cnt<$clients; cnt++ )); do
|
||||
for ((i=0; i<$cmdcnt; i++ )); do
|
||||
maxadmin -pskysql show services;
|
||||
done >/dev/null &
|
||||
done >& /dev/null
|
||||
|
||||
peak=0
|
||||
while [ "`jobs -p`" != "" ]; do
|
||||
jobs >& /dev/null
|
||||
zombies=`maxadmin -pskysql list dcbs | grep -ci zombies`
|
||||
if [ $zombies -gt $peak ] ; then
|
||||
peak=$zombies
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
if [ $peak -gt 10 ]; then
|
||||
echo "High peak zombie count ($peak): Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Zombie collection ($peak): Passed"
|
||||
fi
|
||||
zombies=`maxadmin -pskysql list dcbs | grep -ci zombies`
|
||||
if [ $zombies != "0" ]; then
|
||||
echo "Residual zombie DCBs: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Residual zombie DCBs: Passed"
|
||||
fi
|
||||
sessions=`maxadmin -pskysql list services | awk -F\| '/ cli/ { print $3 }'`
|
||||
if [ $sessions -gt 3 ]; then
|
||||
echo "Session shutdown, $sessions: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Session shutdown: Passed"
|
||||
fi
|
||||
|
||||
sessions=`maxadmin -pskysql list services | awk -F\| '/ cli/ { print $4 }'`
|
||||
|
||||
echo "Test run complete. $passed passes, $failure failures"
|
||||
echo "$sessions CLI sessions executed"
|
||||
exit $failure
|
210
client/test/maxadmin_test.sh
Normal file
210
client/test/maxadmin_test.sh
Normal file
@ -0,0 +1,210 @@
|
||||
#!/bin/sh
|
||||
failure=0
|
||||
passed=0
|
||||
maxadmin -pskysql help >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "Auth test (correct password): Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Auth test (correct password): Passed"
|
||||
fi
|
||||
maxadmin -pwrongpasswd help >& /dev/null
|
||||
if [ $? -eq "0" ]; then
|
||||
echo "Auth test (wrong password): Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Auth test (wrong password): Passed"
|
||||
fi
|
||||
maxadmin --password=skysql help >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "Auth test (long option): Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Auth test (long option): Passed"
|
||||
fi
|
||||
|
||||
maxadmin -pskysql enable log debug >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "Enable debug log: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Enable debug log: Passed"
|
||||
fi
|
||||
|
||||
maxadmin -pskysql enable log trace >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "Enable trace log: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Enable trace log: Passed"
|
||||
fi
|
||||
|
||||
maxadmin -pskysql disable log debug >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "Disable debug log: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Disable debug log: Passed"
|
||||
fi
|
||||
|
||||
maxadmin -pskysql disable log trace >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "Disable trace log: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Disable trace log: Passed"
|
||||
fi
|
||||
|
||||
for cmd in clients dcbs filters listeners modules monitors services servers sessions threads
|
||||
do
|
||||
maxadmin -pskysql list $cmd | grep -s '-' >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "list command ($cmd): Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "list command ($cmd): Passed"
|
||||
fi
|
||||
done
|
||||
|
||||
for cmd in dcbs dbusers epoll filters modules monitors services servers sessions threads users
|
||||
do
|
||||
maxadmin -pskysql show $cmd | grep -s ' ' >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "show command ($cmd): Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "show command ($cmd): Passed"
|
||||
fi
|
||||
done
|
||||
|
||||
master=`maxadmin -pskysql list servers | awk '/Master/ { print $1; }'`
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "Extract master server: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Extract master server: Passed"
|
||||
fi
|
||||
if [ "$master" = "" ]; then
|
||||
echo "Get master server: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Get master server: Passed"
|
||||
fi
|
||||
maxadmin -pskysql show server $master | grep -s 'Master' >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "show server master: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "show server master: Passed"
|
||||
fi
|
||||
|
||||
maxadmin -pskysql set server $master maint >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "set server: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "set server: Passed"
|
||||
fi
|
||||
maxadmin -pskysql list servers | grep $master | grep -s Maint >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "set maintenance mode: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "set maintenance mode: Passed"
|
||||
fi
|
||||
maxadmin -pskysql clear server $master maint >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "clear server: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "clear server: Passed"
|
||||
fi
|
||||
maxadmin -pskysql list servers | grep $master | grep -s Maint >& /dev/null
|
||||
if [ $? -eq "0" ]; then
|
||||
echo "clear maintenance mode: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "clear maintenance mode: Passed"
|
||||
fi
|
||||
|
||||
dcbs=`maxadmin -pskysql list dcbs | awk -F\| '/listening/ { if ( NF > 1 ) print $1 }'`
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "Get dcb listeners: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Get dcb listeners: Passed"
|
||||
fi
|
||||
|
||||
for i in $dcbs
|
||||
do
|
||||
maxadmin -pskysql show dcb $i | grep -s 'listening' >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "show dcb listeners: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "show dcb listeners: Passed"
|
||||
fi
|
||||
done
|
||||
|
||||
sessions=`maxadmin -pskysql list sessions | awk -F\| '/Listener/ { if ( NF > 1 ) print $1 }'`
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "Get listener sessions: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Get listener sessions: Passed"
|
||||
fi
|
||||
|
||||
for i in $sessions
|
||||
do
|
||||
maxadmin -pskysql show session $i | grep -s 'Listener' >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "show session listeners: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "show session listeners: Passed"
|
||||
fi
|
||||
done
|
||||
|
||||
filters=`maxadmin -pskysql list filters | awk -F\| '{ if ( NF > 1 ) print $1 }'| grep -v Options`
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "Get Filter list: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "Get filter list: Passed"
|
||||
fi
|
||||
|
||||
for i in $filters
|
||||
do
|
||||
maxadmin -pskysql show filter $i | grep -s 'Filter' >& /dev/null
|
||||
if [ $? -eq "1" ]; then
|
||||
echo "show filter: Failed"
|
||||
failure=`expr $failure + 1`
|
||||
else
|
||||
passed=`expr $passed + 1`
|
||||
echo "show filter: Passed"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Test run complete. $passed passes, $failure failures"
|
||||
exit $failure
|
2
debian/control
vendored
2
debian/control
vendored
@ -9,7 +9,7 @@ Package: maxscale
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: MaxScale
|
||||
The SkySQL MaxScale is an intelligent proxy that allows forwarding of
|
||||
The MariaDB Corporation MaxScale is an intelligent proxy that allows forwarding of
|
||||
database statements to one or more database servers using complex rules,
|
||||
a semantic understanding of the database statements and the roles of
|
||||
the various servers within the backend cluster of databases.
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# maxscale: The SkySQL MaxScale database proxy
|
||||
# maxscale: The MariaDB Corporation MaxScale database proxy
|
||||
#
|
||||
# description: MaxScale provides database specific proxy functionality
|
||||
#
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# maxscale: The SkySQL MaxScale database proxy
|
||||
# maxscale: The MariaDB Corporation MaxScale database proxy
|
||||
#
|
||||
# description: MaxScale provides database specific proxy functionality
|
||||
#
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# maxscale: The SkySQL MaxScale database proxy
|
||||
# maxscale: The MariaDB Corporation MaxScale database proxy
|
||||
#
|
||||
# description: MaxScale provides database specific proxy functionality
|
||||
#
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# maxscale: The SkySQL MaxScale database proxy
|
||||
# maxscale: The MariaDB Corporation MaxScale database proxy
|
||||
#
|
||||
# description: MaxScale provides database specific proxy functionality
|
||||
#
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@ -75,7 +75,7 @@ int lm_enabled_logfiles_bitmask = 0;
|
||||
* Path to directory in which all files are stored to shared memory
|
||||
* by the OS.
|
||||
*/
|
||||
const char* shm_pathname = "/dev/shm";
|
||||
const char* shm_pathname_prefix = "/dev/shm/";
|
||||
|
||||
/** Logfile ids from call argument '-s' */
|
||||
char* shmem_id_str = NULL;
|
||||
@ -404,7 +404,7 @@ return_succp:
|
||||
|
||||
|
||||
/**
|
||||
* @node Initializes log managing routines in SkySQL Gateway.
|
||||
* @node Initializes log managing routines in MariaDB Corporation MaxScale.
|
||||
*
|
||||
* Parameters:
|
||||
* @param p_ctx - in, give
|
||||
@ -755,7 +755,12 @@ static int logmanager_write_log(
|
||||
break;
|
||||
}
|
||||
}
|
||||
wp[safe_str_len-1] = '\n';
|
||||
/** remove double line feed */
|
||||
if (wp[safe_str_len-2] == '\n')
|
||||
{
|
||||
wp[safe_str_len-2]=' ';
|
||||
}
|
||||
wp[safe_str_len-1] = '\n';
|
||||
blockbuf_unregister(bb);
|
||||
|
||||
/**
|
||||
@ -2063,11 +2068,34 @@ static bool logfile_init(
|
||||
* pointing to shm file is created and located to the file
|
||||
* directory.
|
||||
*/
|
||||
if (store_shmem) {
|
||||
logfile->lf_filepath = strdup(shm_pathname);
|
||||
if (store_shmem)
|
||||
{
|
||||
char* c;
|
||||
pid_t pid = getpid();
|
||||
int len = strlen(shm_pathname_prefix)+
|
||||
get_decimal_len((size_t)pid);
|
||||
|
||||
c = (char *)calloc(len, sizeof(char));
|
||||
|
||||
if (c == NULL)
|
||||
{
|
||||
succp = false;
|
||||
goto file_create_fail;
|
||||
}
|
||||
sprintf(c, "%s%d", shm_pathname_prefix, pid);
|
||||
logfile->lf_filepath = c;
|
||||
|
||||
if (mkdir(c, S_IRWXU | S_IRWXG) != 0 &&
|
||||
errno != EEXIST)
|
||||
{
|
||||
succp = false;
|
||||
goto file_create_fail;
|
||||
}
|
||||
logfile->lf_linkpath = strdup(fn->fn_logpath);
|
||||
logfile->lf_linkpath = add_slash(logfile->lf_linkpath);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
logfile->lf_filepath = strdup(fn->fn_logpath);
|
||||
}
|
||||
logfile->lf_filepath = add_slash(logfile->lf_filepath);
|
||||
@ -2146,7 +2174,7 @@ static bool logfile_init(
|
||||
}
|
||||
}
|
||||
}
|
||||
file_create_fail:
|
||||
file_create_fail:
|
||||
if (namecreatefail || nameconflicts)
|
||||
{
|
||||
logfile->lf_name_seqno += 1;
|
||||
@ -2161,7 +2189,7 @@ static bool logfile_init(
|
||||
free(logfile->lf_full_link_name);
|
||||
logfile->lf_full_link_name = NULL;
|
||||
}
|
||||
|
||||
goto return_with_succp;
|
||||
}
|
||||
} while (namecreatefail || nameconflicts);
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
55
macros.cmake
55
macros.cmake
@ -3,7 +3,8 @@ macro(set_maxscale_version)
|
||||
#MaxScale version number
|
||||
set(MAXSCALE_VERSION_MAJOR "1")
|
||||
set(MAXSCALE_VERSION_MINOR "0")
|
||||
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}-beta")
|
||||
|
||||
endmacro()
|
||||
@ -14,7 +15,7 @@ macro(set_variables)
|
||||
set(INSTALL_DIR "/usr/local/skysql/maxscale/" CACHE PATH "MaxScale installation directory.")
|
||||
|
||||
# Build type
|
||||
set(BUILD_TYPE "Release" CACHE STRING "Build type, possible values are:None (no optimization), Debug, Release.")
|
||||
set(BUILD_TYPE "None" CACHE STRING "Build type, possible values are:None, Debug, Optimized.")
|
||||
|
||||
# hostname or IP address of MaxScale's host
|
||||
set(TEST_HOST "127.0.0.1" CACHE STRING "hostname or IP address of MaxScale's host")
|
||||
@ -50,7 +51,7 @@ macro(set_variables)
|
||||
set(INSTALL_SYSTEM_FILES TRUE CACHE BOOL "Install init.d scripts and ldconf configuration files")
|
||||
|
||||
# Build tests
|
||||
set(BUILD_TESTS TRUE CACHE BOOL "Build tests")
|
||||
set(BUILD_TESTS FALSE CACHE BOOL "Build tests")
|
||||
|
||||
endmacro()
|
||||
|
||||
@ -77,14 +78,20 @@ endmacro()
|
||||
|
||||
macro(check_dirs)
|
||||
|
||||
# This variable is used to prevent redundant checking of dependencies
|
||||
set(DEPS_OK TRUE CACHE BOOL "If all the dependencies were found.")
|
||||
|
||||
# Find the MySQL headers if they were not defined
|
||||
if(DEFINED MYSQL_DIR)
|
||||
message(STATUS "Searching for MySQL headers at: ${MYSQL_DIR}")
|
||||
if(DEBUG_OUTPUT)
|
||||
message(STATUS "Searching for MySQL headers at: ${MYSQL_DIR}")
|
||||
endif()
|
||||
find_path(MYSQL_DIR_LOC mysql.h PATHS ${MYSQL_DIR} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
|
||||
endif()
|
||||
find_path(MYSQL_DIR_LOC mysql.h PATH_SUFFIXES mysql mariadb)
|
||||
message(STATUS "Search returned: ${MYSQL_DIR_LOC}")
|
||||
|
||||
if(DEBUG_OUTPUT)
|
||||
message(STATUS "Search returned: ${MYSQL_DIR_LOC}")
|
||||
endif()
|
||||
if(${MYSQL_DIR_LOC} STREQUAL "MYSQL_DIR_LOC-NOTFOUND")
|
||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||
message(FATAL_ERROR "Fatal Error: MySQL headers were not found.")
|
||||
@ -114,24 +121,32 @@ macro(check_dirs)
|
||||
set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
if (DEFINED EMBEDDED_LIB)
|
||||
message(STATUS "Searching for libmysqld.a at: ${EMBEDDED_LIB}")
|
||||
if(DEBUG_OUTPUT)
|
||||
message(STATUS "Searching for libmysqld.a at: ${EMBEDDED_LIB}")
|
||||
endif()
|
||||
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()
|
||||
message(STATUS "Search returned: ${EMBEDDED_LIB_STATIC}")
|
||||
if(DEBUG_OUTPUT)
|
||||
message(STATUS "Search returned: ${EMBEDDED_LIB_STATIC}")
|
||||
endif()
|
||||
set(EMBEDDED_LIB ${EMBEDDED_LIB_STATIC} CACHE FILEPATH "Path to libmysqld" FORCE)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
|
||||
set(OLD_SUFFIXES "" INTERNAL)
|
||||
|
||||
else()
|
||||
if (DEFINED EMBEDDED_LIB)
|
||||
message(STATUS "Searching for libmysqld.so at: ${EMBEDDED_LIB}")
|
||||
if(DEBUG_OUTPUT)
|
||||
message(STATUS "Searching for libmysqld.so at: ${EMBEDDED_LIB}")
|
||||
endif()
|
||||
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()
|
||||
message(STATUS "Search returned: ${EMBEDDED_LIB_DYNAMIC}")
|
||||
if(DEBUG_OUTPUT)
|
||||
message(STATUS "Search returned: ${EMBEDDED_LIB_DYNAMIC}")
|
||||
endif()
|
||||
set(EMBEDDED_LIB ${EMBEDDED_LIB_DYNAMIC} CACHE FILEPATH "Path to libmysqld" FORCE)
|
||||
|
||||
endif()
|
||||
@ -179,7 +194,7 @@ macro(check_dirs)
|
||||
message(STATUS "Using RabbitMQ libraries found at: ${RABBITMQ_LIB}")
|
||||
endif()
|
||||
|
||||
if(DEFINED RABBITMQ_HEADERS)
|
||||
if(DEFINED RABBITMQ_HEADERS)
|
||||
find_file(RMQ_HEADERS amqp.h PATHS ${RABBITMQ_HEADERS} NO_DEFAULT_PATH)
|
||||
endif()
|
||||
find_file(RMQ_HEADERS amqp.h)
|
||||
@ -193,6 +208,20 @@ macro(check_dirs)
|
||||
|
||||
endif()
|
||||
|
||||
set(DEPS_OK TRUE CACHE BOOL "If all the dependencies were found.")
|
||||
|
||||
endmacro()
|
||||
|
||||
function(subdirs VAR DIRPATH)
|
||||
|
||||
if(${CMAKE_VERSION} VERSION_LESS 2.12 )
|
||||
set(COMP_VAR PATH)
|
||||
else()
|
||||
set(COMP_VAR DIRECTORY)
|
||||
endif()
|
||||
file(GLOB_RECURSE SDIR ${DIRPATH}/*)
|
||||
foreach(LOOP ${SDIR})
|
||||
get_filename_component(LOOP ${LOOP} ${COMP_VAR})
|
||||
list(APPEND ALLDIRS ${LOOP})
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES ALLDIRS)
|
||||
set(${VAR} "${ALLDIRS}" CACHE PATH " " FORCE)
|
||||
endfunction()
|
@ -1,6 +1,5 @@
|
||||
add_library(query_classifier SHARED query_classifier.cc)
|
||||
target_link_libraries(query_classifier ${EMBEDDED_LIB})
|
||||
install(TARGETS query_classifier DESTINATION lib)
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @section LICENCE
|
||||
*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -16,7 +16,7 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* Copyright SkySQL Ab
|
||||
* Copyright MariaDB Corporation Ab
|
||||
*
|
||||
* @file
|
||||
*
|
||||
@ -359,17 +359,37 @@ static bool create_parse_tree(
|
||||
Parser_state parser_state;
|
||||
bool failp = FALSE;
|
||||
const char* virtual_db = "skygw_virtual";
|
||||
|
||||
#if defined(SS_DEBUG_EXTRA)
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"[readwritesplit:create_parse_tree] 1.")));
|
||||
#endif
|
||||
if (parser_state.init(thd, thd->query(), thd->query_length())) {
|
||||
failp = TRUE;
|
||||
goto return_here;
|
||||
}
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
|
||||
/** Set some database to thd so that parsing won't fail because of
|
||||
* missing database. Then parse. */
|
||||
failp = thd->set_db(virtual_db, strlen(virtual_db));
|
||||
#if defined(SS_DEBUG_EXTRA)
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"[readwritesplit:create_parse_tree] 2.")));
|
||||
#endif
|
||||
mysql_reset_thd_for_next_command(thd);
|
||||
|
||||
#if defined(SS_DEBUG_EXTRA)
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"[readwritesplit:create_parse_tree] 3.")));
|
||||
#endif
|
||||
/**
|
||||
* Set some database to thd so that parsing won't fail because of
|
||||
* missing database. Then parse.
|
||||
*/
|
||||
failp = thd->set_db(virtual_db, strlen(virtual_db));
|
||||
#if defined(SS_DEBUG_EXTRA)
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"[readwritesplit:create_parse_tree] 4.")));
|
||||
#endif
|
||||
if (failp) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -377,6 +397,11 @@ static bool create_parse_tree(
|
||||
}
|
||||
failp = parse_sql(thd, &parser_state, NULL);
|
||||
|
||||
#if defined(SS_DEBUG_EXTRA)
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"[readwritesplit:create_parse_tree] 5.")));
|
||||
#endif
|
||||
if (failp) {
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
@ -614,7 +639,17 @@ static skygw_query_type_t resolve_query_type(
|
||||
type |= QUERY_TYPE_PREPARE_NAMED_STMT;
|
||||
goto return_qtype;
|
||||
break;
|
||||
|
||||
|
||||
case SQLCOM_SHOW_DATABASES:
|
||||
type |= QUERY_TYPE_SHOW_DATABASES;
|
||||
goto return_qtype;
|
||||
break;
|
||||
|
||||
case SQLCOM_SHOW_TABLES:
|
||||
type |= QUERY_TYPE_SHOW_TABLES;
|
||||
goto return_qtype;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -798,8 +833,7 @@ static skygw_query_type_t resolve_query_type(
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [resolve_query_type] "
|
||||
"Unknown functype %d. Something "
|
||||
"has gone wrong.",
|
||||
"Functype %d.",
|
||||
pthread_self(),
|
||||
ftype)));
|
||||
break;
|
||||
@ -1350,3 +1384,49 @@ static void parsing_info_set_plain_str(
|
||||
|
||||
pi->pi_query_plain_str = str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a string of query type value.
|
||||
* Caller must free the memory of the resulting string.
|
||||
*
|
||||
* @param qtype Query type value, combination of values listed in
|
||||
* query_classifier.h
|
||||
*
|
||||
* @return string representing the query type value
|
||||
*/
|
||||
char* skygw_get_qtype_str(
|
||||
skygw_query_type_t qtype)
|
||||
{
|
||||
int t1 = (int)qtype;
|
||||
int t2 = 1;
|
||||
skygw_query_type_t t = QUERY_TYPE_UNKNOWN;
|
||||
char* qtype_str = NULL;
|
||||
|
||||
/**
|
||||
* Test values (bits) and clear matching bits from t1 one by one until
|
||||
* t1 is completely cleared.
|
||||
*/
|
||||
while (t1 != 0)
|
||||
{
|
||||
if (t1&t2)
|
||||
{
|
||||
t = (skygw_query_type_t)t2;
|
||||
|
||||
if (qtype_str == NULL)
|
||||
{
|
||||
qtype_str = strdup(STRQTYPE(t));
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t len = strlen(STRQTYPE(t));
|
||||
/** reallocate space for delimiter, new string and termination */
|
||||
qtype_str = (char *)realloc(qtype_str, strlen(qtype_str)+1+len+1);
|
||||
snprintf(qtype_str+strlen(qtype_str), 1+len+1, "|%s", STRQTYPE(t));
|
||||
}
|
||||
/** Remove found value from t1 */
|
||||
t1 &= ~t2;
|
||||
}
|
||||
t2 <<= 1;
|
||||
}
|
||||
return qtype_str;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
This file is distributed as part of the SkySQL Gateway. It is free
|
||||
This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -13,7 +13,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.
|
||||
|
||||
Copyright SkySQL Ab
|
||||
Copyright MariaDB Corporation Ab
|
||||
|
||||
*/
|
||||
|
||||
@ -54,7 +54,9 @@ typedef enum {
|
||||
QUERY_TYPE_PREPARE_STMT = 0x020000, /*< Prepared stmt with id provided by server:all */
|
||||
QUERY_TYPE_EXEC_STMT = 0x040000, /*< Execute prepared statement:master or any */
|
||||
QUERY_TYPE_CREATE_TMP_TABLE = 0x080000, /*< Create temporary table:master (could be all) */
|
||||
QUERY_TYPE_READ_TMP_TABLE = 0x100000 /*< Read temporary table:master (could be any) */
|
||||
QUERY_TYPE_READ_TMP_TABLE = 0x100000, /*< Read temporary table:master (could be any) */
|
||||
QUERY_TYPE_SHOW_DATABASES = 0x200000, /*< Show list of databases */
|
||||
QUERY_TYPE_SHOW_TABLES = 0x400000 /*< Show list of tables */
|
||||
} skygw_query_type_t;
|
||||
|
||||
|
||||
@ -91,6 +93,7 @@ bool parse_query (GWBUF* querybuf);
|
||||
parsing_info_t* parsing_info_init(void (*donefun)(void *));
|
||||
void parsing_info_done(void* ptr);
|
||||
bool query_is_parsed(GWBUF* buf);
|
||||
char* skygw_get_qtype_str(skygw_query_type_t qtype);
|
||||
|
||||
|
||||
EXTERN_C_BLOCK_END
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <mysql.h>
|
||||
|
||||
static char* server_options[] = {
|
||||
"SkySQL Gateway",
|
||||
"MariaDB Corporation MaxScale",
|
||||
"--datadir=./",
|
||||
"--language=./",
|
||||
"--skip-innodb",
|
||||
|
@ -13,7 +13,7 @@ static char datadir[1024] = "";
|
||||
static char mysqldir[1024] = "";
|
||||
|
||||
static char* server_options[] = {
|
||||
"SkySQL Gateway",
|
||||
"MariaDB Corporation MaxScale",
|
||||
"--datadir=",
|
||||
"--default-storage-engine=myisam",
|
||||
NULL
|
||||
|
@ -1,7 +1,7 @@
|
||||
Portions of this software contain modifications contributed by SkySQL, Ab.
|
||||
Portions of this software contain modifications contributed by MariaDB Corporation, Ab.
|
||||
These contributions are used with the following license:
|
||||
|
||||
Copyright (c) 2013, SkySQL Ab. All rights reserved.
|
||||
Copyright (c) 2013, MariaDB Corporation Ab. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -12,7 +12,7 @@ are met:
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
* Neither the name of the SkySQL Ab. nor the names of its
|
||||
* Neither the name of the MariaDB Corporation Ab. nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written
|
||||
permission.
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights
|
||||
reserved.
|
||||
Copyright (c) 2013, SkySQL Ab
|
||||
Copyright (c) 2013, MariaDB Corporation Ab
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
SkySQL, Ab. Those modifications are gratefully acknowledged and are described
|
||||
MariaDB Corporation, Ab. Those modifications are gratefully acknowledged and are described
|
||||
briefly in the source code.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
SkySQL change details:
|
||||
MariaDB Corporation change details:
|
||||
- Removed unnecessary file driver
|
||||
|
||||
Author: Jan Lindström (jan.lindstrom@skysql.com
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights
|
||||
reserved.
|
||||
Copyright (c) 2013, SkySQL Ab
|
||||
Copyright (c) 2013-2014, MariaDB Corporation Ab
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
SkySQL, Ab. Those modifications are gratefully acknowledged and are described
|
||||
MariaDB Corporation, Ab. Those modifications are gratefully acknowledged and are described
|
||||
briefly in the source code.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights
|
||||
reserved.
|
||||
Copyright (c) 2013, SkySQL Ab
|
||||
Copyright (c) 2013, MariaDB Corporation Ab
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
SkySQL, Ab. Those modifications are gratefully acknowledged and are described
|
||||
MariaDB Corporation, Ab. Those modifications are gratefully acknowledged and are described
|
||||
briefly in the source code.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
SkySQL change details:
|
||||
MariaDB Corporation change details:
|
||||
- Added GTID event handler
|
||||
|
||||
Author: Jan Lindström (jan.lindstrom@skysql.com
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights
|
||||
reserved.
|
||||
Copyright (c) 2013, SkySQL Ab
|
||||
Copyright (c) 2013-2014, MariaDB Corporation Ab
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
SkySQL, Ab. Those modifications are gratefully acknowledged and are described
|
||||
MariaDB Corporation, Ab. Those modifications are gratefully acknowledged and are described
|
||||
briefly in the source code.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
SkySQL change details:
|
||||
MariaDB Corporation change details:
|
||||
- Added GTID event handler
|
||||
|
||||
Author: Jan Lindström (jan.lindstrom@skysql.com
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights
|
||||
reserved.
|
||||
Copyright (c) 2013, SkySQL Ab
|
||||
Copyright (c) 2013, MariaDB Corporation Ab
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
SkySQL, Ab. Those modifications are gratefully acknowledged and are described
|
||||
MariaDB Corporation, Ab. Those modifications are gratefully acknowledged and are described
|
||||
briefly in the source code.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
SkySQL change details:
|
||||
MariaDB Corporation change details:
|
||||
- Added support for setting binlog position based on GTID
|
||||
- Added support for MySQL and MariDB server types
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights
|
||||
reserved.
|
||||
Copyright (c) 2013, SkySQL Ab
|
||||
Copyright (c) 2013-2014, MariaDB Corporation Ab
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
SkySQL, Ab. Those modifications are gratefully acknowledged and are described
|
||||
MariaDB Corporation, Ab. Those modifications are gratefully acknowledged and are described
|
||||
briefly in the source code.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
SkySQL change details:
|
||||
MariaDB Corporation change details:
|
||||
- Added support for setting binlog position based on GTID
|
||||
- Added support for MySQL and MariDB server types
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights
|
||||
reserved.
|
||||
Copyright (c) 2013, SkySQL Ab
|
||||
Copyright (c) 2013, MariaDB Corporation Ab
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
SkySQL, Ab. Those modifications are gratefully acknowledged and are described
|
||||
MariaDB Corporation, Ab. Those modifications are gratefully acknowledged and are described
|
||||
briefly in the source code.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -23,7 +23,7 @@
|
||||
02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
SkySQL change details:
|
||||
MariaDB Corporation change details:
|
||||
- Added support for GTID event handling for both MySQL and MariaDB
|
||||
|
||||
Author: Jan Lindström (jan.lindstrom@skysql.com
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights
|
||||
reserved.
|
||||
Copyright (c) 2013, SkySQL Ab
|
||||
Copyright (c) 2013-2014, MariaDB Corporation Ab
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
SkySQL, Ab. Those modifications are gratefully acknowledged and are described
|
||||
MariaDB Corporation, Ab. Those modifications are gratefully acknowledged and are described
|
||||
briefly in the source code.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
SkySQL change details:
|
||||
MariaDB Corporation change details:
|
||||
- Added support for GTID event handling for both MySQL and MariaDB
|
||||
- Added support for setting binlog position based on GTID
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights
|
||||
reserved.
|
||||
Copyright (c) 2013, SkySQL Ab
|
||||
Copyright (c) 2013, MariaDB Corporation Ab
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
SkySQL, Ab. Those modifications are gratefully acknowledged and are described
|
||||
MariaDB Corporation, Ab. Those modifications are gratefully acknowledged and are described
|
||||
briefly in the source code.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
SkySQL change details:
|
||||
MariaDB Corporation change details:
|
||||
- Added support for GTID event handling for both MySQL and MariaDB
|
||||
|
||||
Author: Jan Lindström (jan.lindstrom@skysql.com
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights
|
||||
reserved.
|
||||
Copyright (c) 2013, SkySQL Ab
|
||||
Copyright (c) 2013-2014, MariaDB Corporation Ab
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
SkySQL, Ab. Those modifications are gratefully acknowledged and are described
|
||||
MariaDB Corporation, Ab. Those modifications are gratefully acknowledged and are described
|
||||
briefly in the source code.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
SkySQL change details:
|
||||
MariaDB Corporation change details:
|
||||
- Added support for GTID event handling for both MySQL and MariaDB
|
||||
|
||||
Author: Jan Lindström (jan.lindstrom@skysql.com
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
Copyright (C) 2013, SkySQL Ab
|
||||
Copyright (C) 2013, MariaDB Corporation Ab
|
||||
|
||||
|
||||
This file is distributed as part of the SkySQL Gateway. It is free
|
||||
This file is distributed as part of the MariaDB Corporation 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.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
Copyright (C) 2013, SkySQL Ab
|
||||
Copyright (C) 2013-2014, MariaDB Corporation Ab
|
||||
|
||||
This file is distributed as part of the SkySQL Gateway. It is free
|
||||
This file is distributed as part of the MariaDB Corporation 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.
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
Copyright (C) 2013, SkySQL Ab
|
||||
Copyright (C) 2013-2014, MariaDB Corporation Ab
|
||||
|
||||
|
||||
This file is distributed as part of the SkySQL Gateway. It is free
|
||||
This file is distributed as part of the MariaDB Corporation 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.
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights
|
||||
reserved.
|
||||
Copyright (c) 2013, SkySQL Ab
|
||||
Copyright (c) 2013, MariaDB Corporation Ab
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
SkySQL, Ab. Those modifications are gratefully acknowledged and are described
|
||||
MariaDB Corporation, Ab. Those modifications are gratefully acknowledged and are described
|
||||
briefly in the source code.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
SkySQL change details:
|
||||
MariaDB Corporation change details:
|
||||
- Added support for GTID event handling for both MySQL and MariaDB
|
||||
|
||||
Author: Jan Lindström (jan.lindstrom@skysql.com
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights
|
||||
reserved.
|
||||
Copyright (c) 2013, SkySQL Ab
|
||||
Copyright (c) 2013, MariaDB Corporation Ab
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
SkySQL, Ab. Those modifications are gratefully acknowledged and are described
|
||||
MariaDB Corporation, Ab. Those modifications are gratefully acknowledged and are described
|
||||
briefly in the source code.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
SkySQL change details:
|
||||
MariaDB Corporation change details:
|
||||
- Added support for GTID event handling for both MySQL and MariaDB
|
||||
- Added support for starting binlog dump from GTID position
|
||||
- Added error handling using exceptions
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights
|
||||
reserved.
|
||||
Copyright (c) 2013, SkySQL Ab
|
||||
Copyright (c) 2013-2014, MariaDB Corporation Ab
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
SkySQL, Ab. Those modifications are gratefully acknowledged and are described
|
||||
MariaDB Corporation, Ab. Those modifications are gratefully acknowledged and are described
|
||||
briefly in the source code.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
SkySQL change details:
|
||||
MariaDB Corporation change details:
|
||||
- Added support for GTID event handling for both MySQL and MariaDB
|
||||
- Added support for starting binlog dump from GTID position
|
||||
- Added support for MariaDB server
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
Copyright (C) 2013, SkySQL Ab
|
||||
Copyright (C) 2013, MariaDB Corporation Ab
|
||||
|
||||
|
||||
This file is distributed as part of the SkySQL Gateway. It is free
|
||||
This file is distributed as part of the MariaDB Corporation 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.
|
||||
|
@ -14,7 +14,7 @@ echo "Looking for MaxScale in [${BINARY_PATH}]"
|
||||
|
||||
if [ -s "${BINARY_PATH}/bin/maxscale" ]; then
|
||||
if [ -x "${BINARY_PATH}/bin/maxscale" ]; then
|
||||
MAXSCALE_VERSION=`strings ${BINARY_PATH}/bin/maxscale | grep "SkySQL MaxScale" | awk '{print $3}' | head -1`
|
||||
MAXSCALE_VERSION=`strings ${BINARY_PATH}/bin/maxscale | grep "MariaDB Corporation MaxScale" | awk '{print $3}' | head -1`
|
||||
echo "Found MaxScale, version: ${MAXSCALE_VERSION}"
|
||||
fi
|
||||
else
|
||||
|
@ -1,4 +1,4 @@
|
||||
# This file is distributed as part of the SkySQL Gateway. It is free
|
||||
# This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
# Copyright MariaDB Corporation Ab 2013
|
||||
#
|
||||
# Revision History
|
||||
# Date Who Description
|
||||
|
@ -1,11 +1,12 @@
|
||||
file(GLOB FULLCORE_SRC *.c)
|
||||
add_library(fullcore STATIC ${FULLCORE_SRC})
|
||||
target_link_libraries(fullcore log_manager utils pthread ${EMBEDDED_LIB} ssl aio rt crypt dl crypto inih z m stdc++)
|
||||
|
||||
if(BUILD_TESTS)
|
||||
file(GLOB FULLCORE_SRC *.c)
|
||||
add_library(fullcore STATIC ${FULLCORE_SRC})
|
||||
target_link_libraries(fullcore log_manager utils pthread ${EMBEDDED_LIB} ssl aio rt crypt dl crypto inih z m stdc++)
|
||||
endif()
|
||||
add_executable(maxscale atomic.c buffer.c spinlock.c gateway.c
|
||||
gw_utils.c utils.c dcb.c load_utils.c session.c service.c server.c
|
||||
poll.c config.c users.c hashtable.c dbusers.c thread.c gwbitmask.c
|
||||
monitor.c adminusers.c secrets.c filter.c modutil.c hint.c housekeeper.c)
|
||||
gw_utils.c utils.c dcb.c load_utils.c session.c service.c server.c
|
||||
poll.c config.c users.c hashtable.c dbusers.c thread.c gwbitmask.c
|
||||
monitor.c adminusers.c secrets.c filter.c modutil.c hint.c housekeeper.c)
|
||||
target_link_libraries(maxscale ${EMBEDDED_LIB} log_manager utils ssl aio pthread crypt dl crypto inih z rt m stdc++)
|
||||
install(TARGETS maxscale DESTINATION bin)
|
||||
|
||||
@ -18,5 +19,5 @@ target_link_libraries(maxpasswd log_manager utils pthread crypt crypto)
|
||||
install(TARGETS maxpasswd DESTINATION bin)
|
||||
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(test)
|
||||
endif()
|
@ -1,4 +1,4 @@
|
||||
# This file is distributed as part of the SkySQL Gateway. It is free
|
||||
# This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
# Copyright MariaDB Corporation Ab 2013
|
||||
#
|
||||
# Revision History
|
||||
# Date Who Description
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -13,11 +13,11 @@
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright SkySQL Ab 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file buffer.h - The Gateway buffer management functions
|
||||
* @file buffer.h - The MaxScale buffer management functions
|
||||
*
|
||||
* The buffer management is based on the principle of a linked list
|
||||
* of variable size buffer, the intention beign to allow longer
|
||||
@ -87,7 +87,7 @@ SHARED_BUF *sbuf;
|
||||
}
|
||||
spinlock_init(&rval->gwbuf_lock);
|
||||
rval->start = sbuf->data;
|
||||
rval->end = rval->start + size;
|
||||
rval->end = (void*)((uint8_t*)rval->start + size);
|
||||
sbuf->refcount = 1;
|
||||
rval->sbuf = sbuf;
|
||||
rval->next = NULL;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -123,12 +123,6 @@ DCB *rval;
|
||||
rval->dcb_errhandle_called = false;
|
||||
#endif
|
||||
rval->dcb_role = role;
|
||||
#if 1
|
||||
simple_mutex_init(&rval->dcb_write_lock, "DCB write mutex");
|
||||
simple_mutex_init(&rval->dcb_read_lock, "DCB read mutex");
|
||||
rval->dcb_write_active = false;
|
||||
rval->dcb_read_active = false;
|
||||
#endif
|
||||
spinlock_init(&rval->dcb_initlock);
|
||||
spinlock_init(&rval->writeqlock);
|
||||
spinlock_init(&rval->delayqlock);
|
||||
@ -141,6 +135,13 @@ DCB *rval;
|
||||
rval->polloutbusy = 0;
|
||||
rval->writecheck = 0;
|
||||
rval->fd = -1;
|
||||
|
||||
rval->evq.next = NULL;
|
||||
rval->evq.prev = NULL;
|
||||
rval->evq.pending_events = 0;
|
||||
rval->evq.processing = 0;
|
||||
spinlock_init(&rval->evq.eventqlock);
|
||||
|
||||
memset(&rval->stats, 0, sizeof(DCBSTATS)); // Zero the statistics
|
||||
rval->state = DCB_STATE_ALLOC;
|
||||
bitmask_init(&rval->memdata.bitmask);
|
||||
@ -218,43 +219,11 @@ dcb_add_to_zombieslist(DCB *dcb)
|
||||
spinlock_release(&zombiespin);
|
||||
return;
|
||||
}
|
||||
#if 1
|
||||
/*<
|
||||
* Add closing dcb to the top of the list.
|
||||
*/
|
||||
dcb->memdata.next = zombies;
|
||||
zombies = dcb;
|
||||
#else
|
||||
if (zombies == NULL) {
|
||||
zombies = dcb;
|
||||
} else {
|
||||
DCB *ptr = zombies;
|
||||
while (ptr->memdata.next)
|
||||
{
|
||||
ss_info_dassert(
|
||||
ptr->memdata.next->state == DCB_STATE_ZOMBIE,
|
||||
"Next zombie is not in DCB_STATE_ZOMBIE state");
|
||||
|
||||
ss_info_dassert(
|
||||
ptr != dcb,
|
||||
"Attempt to add DCB to zombies list although it "
|
||||
"is already there.");
|
||||
|
||||
if (ptr == dcb)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Attempt to add DCB to zombies "
|
||||
"list when it is already in the list")));
|
||||
break;
|
||||
}
|
||||
ptr = ptr->memdata.next;
|
||||
}
|
||||
if (ptr != dcb) {
|
||||
ptr->memdata.next = dcb;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/*<
|
||||
* Set state which indicates that it has been added to zombies
|
||||
* list.
|
||||
@ -389,8 +358,6 @@ DCB_CALLBACK *cb;
|
||||
spinlock_release(&dcb->cb_lock);
|
||||
|
||||
bitmask_free(&dcb->memdata.bitmask);
|
||||
simple_mutex_done(&dcb->dcb_read_lock);
|
||||
simple_mutex_done(&dcb->dcb_write_lock);
|
||||
free(dcb);
|
||||
}
|
||||
|
||||
@ -404,15 +371,10 @@ DCB_CALLBACK *cb;
|
||||
* the memdata.bitmask then the DCB is no longer able to be
|
||||
* referenced and it can be finally removed.
|
||||
*
|
||||
* The excluded DCB allows a thread to exclude a DCB from zombie processing.
|
||||
* It is used when a thread calls dcb_process_zombies when there is
|
||||
* a DCB that the caller knows it will continue processing with.
|
||||
*
|
||||
* @param threadid The thread ID of the caller
|
||||
* @param excluded The DCB the thread currently uses, NULL or valid DCB.
|
||||
*/
|
||||
DCB *
|
||||
dcb_process_zombies(int threadid, DCB *excluded)
|
||||
dcb_process_zombies(int threadid)
|
||||
{
|
||||
DCB *ptr, *lptr;
|
||||
DCB* dcb_list = NULL;
|
||||
@ -446,9 +408,10 @@ bool succp = false;
|
||||
CHK_DCB(ptr);
|
||||
|
||||
/*
|
||||
* Skip processing of the excluded DCB
|
||||
* Skip processing of DCB's that are
|
||||
* in the event queue waiting to be processed.
|
||||
*/
|
||||
if (ptr == excluded)
|
||||
if (ptr->evq.next || ptr->evq.prev)
|
||||
{
|
||||
lptr = ptr;
|
||||
ptr = ptr->memdata.next;
|
||||
@ -522,7 +485,6 @@ bool succp = false;
|
||||
/*<
|
||||
* Close file descriptor and move to clean-up phase.
|
||||
*/
|
||||
ss_dassert(excluded != dcb);
|
||||
rc = close(dcb->fd);
|
||||
|
||||
if (rc < 0) {
|
||||
@ -1255,7 +1217,7 @@ printDCB(DCB *dcb)
|
||||
static void
|
||||
spin_reporter(void *dcb, char *desc, int value)
|
||||
{
|
||||
dcb_printf((DCB *)dcb, "\t\t%-35s %d\n", desc, value);
|
||||
dcb_printf((DCB *)dcb, "\t\t%-40s %d\n", desc, value);
|
||||
}
|
||||
|
||||
|
||||
@ -1316,10 +1278,6 @@ DCB *dcb;
|
||||
dcb_printf(pdcb, "\t\tNo. of Writes: %d\n", dcb->stats.n_writes);
|
||||
dcb_printf(pdcb, "\t\tNo. of Buffered Writes: %d\n", dcb->stats.n_buffered);
|
||||
dcb_printf(pdcb, "\t\tNo. of Accepts: %d\n", dcb->stats.n_accepts);
|
||||
dcb_printf(pdcb, "\t\tNo. of busy polls: %d\n", dcb->stats.n_busypolls);
|
||||
dcb_printf(pdcb, "\t\tNo. of read rechecks: %d\n", dcb->stats.n_readrechecks);
|
||||
dcb_printf(pdcb, "\t\tNo. of busy write polls: %d\n", dcb->stats.n_busywrpolls);
|
||||
dcb_printf(pdcb, "\t\tNo. of write rechecks: %d\n", dcb->stats.n_writerechecks);
|
||||
dcb_printf(pdcb, "\t\tNo. of High Water Events: %d\n", dcb->stats.n_high_water);
|
||||
dcb_printf(pdcb, "\t\tNo. of Low Water Events: %d\n", dcb->stats.n_low_water);
|
||||
if (dcb->flags & DCBF_CLONE)
|
||||
@ -1427,10 +1385,6 @@ dprintDCB(DCB *pdcb, DCB *dcb)
|
||||
dcb->stats.n_buffered);
|
||||
dcb_printf(pdcb, "\t\tNo. of Accepts: %d\n",
|
||||
dcb->stats.n_accepts);
|
||||
dcb_printf(pdcb, "\t\tNo. of busy polls: %d\n", dcb->stats.n_busypolls);
|
||||
dcb_printf(pdcb, "\t\tNo. of read rechecks: %d\n", dcb->stats.n_readrechecks);
|
||||
dcb_printf(pdcb, "\t\tNo. of busy write polls: %d\n", dcb->stats.n_busywrpolls);
|
||||
dcb_printf(pdcb, "\t\tNo. of write rechecks: %d\n", dcb->stats.n_writerechecks);
|
||||
dcb_printf(pdcb, "\t\tNo. of High Water Events: %d\n",
|
||||
dcb->stats.n_high_water);
|
||||
dcb_printf(pdcb, "\t\tNo. of Low Water Events: %d\n",
|
||||
@ -1955,99 +1909,6 @@ int rval = 0;
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the EPOLLIN event. Take care of calling the protocol
|
||||
* read entry point and managing multiple threads competing for the DCB
|
||||
* without blocking those threads.
|
||||
*
|
||||
* This mechanism does away with the need for a mutex on the EPOLLIN event
|
||||
* and instead implements a queuing mechanism in which nested events are
|
||||
* queued on the DCB such that when the thread processing the first event
|
||||
* returns it will read the queued event and process it. This allows the
|
||||
* thread that would otherwise have to wait to process the nested event
|
||||
* to return immediately and and process other events.
|
||||
*
|
||||
* @param dcb The DCB that has data available
|
||||
* @param thread_id The ID of the calling thread
|
||||
* @param nozombies If non-zero then do not do zombie processing
|
||||
*/
|
||||
void
|
||||
dcb_pollin(DCB *dcb, int thread_id, int nozombies)
|
||||
{
|
||||
|
||||
spinlock_acquire(&dcb->pollinlock);
|
||||
if (dcb->pollinbusy == 0)
|
||||
{
|
||||
dcb->pollinbusy = 1;
|
||||
do {
|
||||
if (dcb->readcheck)
|
||||
{
|
||||
dcb->stats.n_readrechecks++;
|
||||
if (!nozombies)
|
||||
dcb_process_zombies(thread_id, dcb);
|
||||
}
|
||||
dcb->readcheck = 0;
|
||||
spinlock_release(&dcb->pollinlock);
|
||||
dcb->func.read(dcb);
|
||||
spinlock_acquire(&dcb->pollinlock);
|
||||
} while (dcb->readcheck);
|
||||
dcb->pollinbusy = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dcb->stats.n_busypolls++;
|
||||
dcb->readcheck = 1;
|
||||
}
|
||||
spinlock_release(&dcb->pollinlock);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called by the EPOLLOUT event. Take care of calling the protocol
|
||||
* write_ready entry point and managing multiple threads competing for the DCB
|
||||
* without blocking those threads.
|
||||
*
|
||||
* This mechanism does away with the need for a mutex on the EPOLLOUT event
|
||||
* and instead implements a queuing mechanism in which nested events are
|
||||
* queued on the DCB such that when the thread processing the first event
|
||||
* returns it will read the queued event and process it. This allows the
|
||||
* thread that would otherwise have to wait to process the nested event
|
||||
* to return immediately and and process other events.
|
||||
*
|
||||
* @param dcb The DCB thats available for writes
|
||||
* @param thread_id The ID of the calling thread
|
||||
* @param nozombies If non-zero then do not do zombie processing
|
||||
*/
|
||||
void
|
||||
dcb_pollout(DCB *dcb, int thread_id, int nozombies)
|
||||
{
|
||||
|
||||
spinlock_acquire(&dcb->polloutlock);
|
||||
if (dcb->polloutbusy == 0)
|
||||
{
|
||||
dcb->polloutbusy = 1;
|
||||
do {
|
||||
if (dcb->writecheck)
|
||||
{
|
||||
if (!nozombies)
|
||||
dcb_process_zombies(thread_id, dcb);
|
||||
dcb->stats.n_writerechecks++;
|
||||
}
|
||||
dcb->writecheck = 0;
|
||||
spinlock_release(&dcb->polloutlock);
|
||||
dcb->func.write_ready(dcb);
|
||||
spinlock_acquire(&dcb->polloutlock);
|
||||
} while (dcb->writecheck);
|
||||
dcb->polloutbusy = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dcb->stats.n_busywrpolls++;
|
||||
dcb->writecheck = 1;
|
||||
}
|
||||
spinlock_release(&dcb->polloutlock);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the next DCB in the list of all DCB's
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of MaxScale from SkySQL. It is free
|
||||
* This file is distributed as part of MaxScale from 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.
|
||||
@ -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
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*
|
||||
*/
|
||||
|
||||
@ -88,7 +88,7 @@ extern int lm_enabled_logfiles_bitmask;
|
||||
* is not fixed here and will be updated elsewhere.
|
||||
*/
|
||||
static char* server_options[] = {
|
||||
"SkySQL Gateway",
|
||||
"MariaDB Corporation MaxScale",
|
||||
"--no-defaults",
|
||||
"--datadir=",
|
||||
"--language=",
|
||||
@ -387,7 +387,7 @@ static bool file_write_header(
|
||||
*t = time(NULL);
|
||||
*tm = *localtime(t);
|
||||
|
||||
header_buf1 = "\n\nSkySQL MaxScale " MAXSCALE_VERSION "\t";
|
||||
header_buf1 = "\n\nMariaDB Corporation MaxScale " MAXSCALE_VERSION "\t";
|
||||
header_buf2 = strdup(asctime(tm));
|
||||
|
||||
if (header_buf2 == NULL) {
|
||||
@ -1539,7 +1539,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE,
|
||||
"SkySQL MaxScale %s (C) SkySQL Ab 2013,2014",
|
||||
"MariaDB Corporation MaxScale %s (C) MariaDB Corporation Ab 2013-2014",
|
||||
MAXSCALE_VERSION)));
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE,
|
||||
@ -1646,6 +1646,7 @@ void
|
||||
shutdown_server()
|
||||
{
|
||||
poll_shutdown();
|
||||
hkshutdown();
|
||||
log_flush_shutdown();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -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
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -42,6 +42,8 @@ static HKTASK *tasks = NULL;
|
||||
*/
|
||||
static SPINLOCK tasklock = SPINLOCK_INIT;
|
||||
|
||||
static int do_shutdown = 0;
|
||||
|
||||
static void hkthread(void *);
|
||||
|
||||
/**
|
||||
@ -172,6 +174,8 @@ void *taskdata;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (do_shutdown)
|
||||
return;
|
||||
thread_millisleep(1000);
|
||||
now = time(0);
|
||||
spinlock_acquire(&tasklock);
|
||||
@ -194,3 +198,13 @@ void *taskdata;
|
||||
spinlock_release(&tasklock);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to shutdown the housekeeper
|
||||
*
|
||||
*/
|
||||
void
|
||||
hkshutdown()
|
||||
{
|
||||
do_shutdown = 1;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of MaxScale from SkySQL. It is free
|
||||
* This file is distributed as part of MaxScale from 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.
|
||||
@ -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
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -76,7 +76,7 @@ unsigned char *ptr;
|
||||
ptr = GWBUF_DATA(buf);
|
||||
*length = *ptr++;
|
||||
*length += (*ptr++ << 8);
|
||||
*length += (*ptr++ << 8);
|
||||
*length += (*ptr++ << 16);
|
||||
ptr += 2; // Skip sequence id and COM_QUERY byte
|
||||
*length = *length - 1;
|
||||
*sql = (char *)ptr;
|
||||
@ -111,7 +111,7 @@ unsigned char *ptr;
|
||||
ptr = GWBUF_DATA(buf);
|
||||
*residual = *ptr++;
|
||||
*residual += (*ptr++ << 8);
|
||||
*residual += (*ptr++ << 8);
|
||||
*residual += (*ptr++ << 16);
|
||||
ptr += 2; // Skip sequence id and COM_QUERY byte
|
||||
*residual = *residual - 1;
|
||||
*length = GWBUF_LENGTH(buf) - 5;
|
||||
@ -143,7 +143,7 @@ GWBUF *addition;
|
||||
ptr = GWBUF_DATA(orig);
|
||||
length = *ptr++;
|
||||
length += (*ptr++ << 8);
|
||||
length += (*ptr++ << 8);
|
||||
length += (*ptr++ << 16);
|
||||
ptr += 2; // Skip sequence id and COM_QUERY byte
|
||||
|
||||
newlength = strlen(sql);
|
||||
@ -178,11 +178,11 @@ GWBUF *addition;
|
||||
*
|
||||
* @param buf GWBUF buffer including the query
|
||||
*
|
||||
* @return Plaint text query if the packet type is COM_QUERY. Otherwise return
|
||||
* @return Plain text query if the packet type is COM_QUERY. Otherwise return
|
||||
* a string including the packet type.
|
||||
*/
|
||||
char* modutil_get_query(
|
||||
GWBUF* buf)
|
||||
char *
|
||||
modutil_get_query(GWBUF *buf)
|
||||
{
|
||||
uint8_t* packet;
|
||||
mysql_server_cmd_t packet_type;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -234,17 +234,17 @@ MONITOR *ptr;
|
||||
|
||||
spinlock_acquire(&monLock);
|
||||
ptr = allMonitors;
|
||||
dcb_printf(dcb, "+----------------------+---------------------\n");
|
||||
dcb_printf(dcb, "| %-20s | Status\n", "Monitor");
|
||||
dcb_printf(dcb, "+----------------------+---------------------\n");
|
||||
dcb_printf(dcb, "---------------------+---------------------\n");
|
||||
dcb_printf(dcb, "%-20s | Status\n", "Monitor");
|
||||
dcb_printf(dcb, "---------------------+---------------------\n");
|
||||
while (ptr)
|
||||
{
|
||||
dcb_printf(dcb, "| %-20s | %s\n", ptr->name,
|
||||
dcb_printf(dcb, "%-20s | %s\n", ptr->name,
|
||||
ptr->state & MONITOR_STATE_RUNNING
|
||||
? "Running" : "Stopped");
|
||||
ptr = ptr->next;
|
||||
}
|
||||
dcb_printf(dcb, "+----------------------+---------------------\n");
|
||||
dcb_printf(dcb, "---------------------+---------------------\n");
|
||||
spinlock_release(&monLock);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -30,6 +30,13 @@
|
||||
#include <gw.h>
|
||||
#include <config.h>
|
||||
#include <housekeeper.h>
|
||||
#include <mysql.h>
|
||||
|
||||
#define PROFILE_POLL 1
|
||||
|
||||
#if PROFILE_POLL
|
||||
#include <rdtsc.h>
|
||||
#endif
|
||||
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
|
||||
@ -47,6 +54,11 @@ extern int lm_enabled_logfiles_bitmask;
|
||||
* etc.
|
||||
* 23/09/14 Mark Riddoch Make use of RDHUP conditional to allow CentOS 5
|
||||
* builds.
|
||||
* 24/09/14 Mark Riddoch Introduction of the event queue for processing the
|
||||
* incoming events rather than processing them immediately
|
||||
* in the loop after the epoll_wait. This allows for better
|
||||
* thread utilisaiton and fairer scheduling of the event
|
||||
* processing.
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
@ -65,6 +77,11 @@ static GWBITMASK poll_mask;
|
||||
static simple_mutex_t epoll_wait_mutex; /*< serializes calls to epoll_wait */
|
||||
#endif
|
||||
static int n_waiting = 0; /*< No. of threads in epoll_wait */
|
||||
static int process_pollq(int thread_id);
|
||||
|
||||
|
||||
DCB *eventq = NULL;
|
||||
SPINLOCK pollqlock = SPINLOCK_INIT;
|
||||
|
||||
/**
|
||||
* Thread load average, this is the average number of descriptors in each
|
||||
@ -125,6 +142,8 @@ static struct {
|
||||
int n_nothreads; /*< Number of times no threads are polling */
|
||||
int n_fds[MAXNFDS]; /*< Number of wakeups with particular
|
||||
n_fds value */
|
||||
int evq_length; /*< Event queue length */
|
||||
int evq_max; /*< Maximum event queue length */
|
||||
} pollStats;
|
||||
|
||||
/**
|
||||
@ -338,6 +357,17 @@ return_rc:
|
||||
* deschedule a process if a timeout is included, but will not do this if a 0 timeout
|
||||
* value is given. this improves performance when the gateway is under heavy load.
|
||||
*
|
||||
* In order to provide a fairer means of sharign the threads between the different
|
||||
* DCB's the poll mechanism has been decoupled from the processing of the events.
|
||||
* The events are now recieved via the epoll_wait call, a queue of DCB's that have
|
||||
* events pending is maintained and as new events arrive the DCB is added to the end
|
||||
* of this queue. If an eent arrives for a DCB alreayd in the queue, then the event
|
||||
* bits are added to the DCB but the DCB mantains the same point in the queue unless
|
||||
* the original events are already being processed. If they are being processed then
|
||||
* the DCB is moved to the back of the queue, this means that a DCB that is receiving
|
||||
* events at a high rate will not block the execution of events for other DCB's and
|
||||
* should result in a fairer polling strategy.
|
||||
*
|
||||
* @param arg The thread ID passed as a void * to satisfy the threading package
|
||||
*/
|
||||
void
|
||||
@ -346,8 +376,6 @@ poll_waitevents(void *arg)
|
||||
struct epoll_event events[MAX_EVENTS];
|
||||
int i, nfds;
|
||||
int thread_id = (int)arg;
|
||||
bool no_op = false;
|
||||
static bool process_zombies_only = false; /*< flag for all threads */
|
||||
DCB *zombies = NULL;
|
||||
|
||||
/** Add this thread to the bitmask of running polling threads */
|
||||
@ -362,20 +390,19 @@ DCB *zombies = NULL;
|
||||
|
||||
while (1)
|
||||
{
|
||||
/* Process of the queue of waiting requests */
|
||||
while (do_shutdown == 0 && process_pollq(thread_id))
|
||||
{
|
||||
if (thread_data)
|
||||
thread_data[thread_id].state = THREAD_ZPROCESSING;
|
||||
zombies = dcb_process_zombies(thread_id);
|
||||
}
|
||||
|
||||
atomic_add(&n_waiting, 1);
|
||||
#if BLOCKINGPOLL
|
||||
nfds = epoll_wait(epoll_fd, events, MAX_EVENTS, -1);
|
||||
atomic_add(&n_waiting, -1);
|
||||
#else /* BLOCKINGPOLL */
|
||||
if (!no_op) {
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] MaxScale thread "
|
||||
"%d > epoll_wait <",
|
||||
pthread_self(),
|
||||
thread_id)));
|
||||
no_op = TRUE;
|
||||
}
|
||||
#if MUTEX_EPOLL
|
||||
simple_mutex_lock(&epoll_wait_mutex, TRUE);
|
||||
#endif
|
||||
@ -396,32 +423,19 @@ DCB *zombies = NULL;
|
||||
pthread_self(),
|
||||
nfds,
|
||||
eno)));
|
||||
no_op = FALSE;
|
||||
}
|
||||
else if (nfds == 0)
|
||||
/*
|
||||
* If there are no new descriptors from the non-blocking call
|
||||
* and nothing to proces on the event queue then for do a
|
||||
* blocking call to epoll_wait.
|
||||
*/
|
||||
else if (nfds == 0 && process_pollq(thread_id) == 0)
|
||||
{
|
||||
atomic_add(&n_waiting, -1);
|
||||
if (process_zombies_only) {
|
||||
#if MUTEX_EPOLL
|
||||
simple_mutex_unlock(&epoll_wait_mutex);
|
||||
#endif
|
||||
goto process_zombies;
|
||||
} else {
|
||||
nfds = epoll_wait(epoll_fd,
|
||||
atomic_add(&n_waiting, 1);
|
||||
nfds = epoll_wait(epoll_fd,
|
||||
events,
|
||||
MAX_EVENTS,
|
||||
EPOLL_TIMEOUT);
|
||||
/*<
|
||||
* When there are zombies to be cleaned up but
|
||||
* no client requests, allow all threads to call
|
||||
* dcb_process_zombies without having to wait
|
||||
* for the timeout.
|
||||
*/
|
||||
if (nfds == 0 && dcb_get_zombies() != NULL)
|
||||
{
|
||||
process_zombies_only = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -457,228 +471,64 @@ DCB *zombies = NULL;
|
||||
atomic_add(&load_samples, 1);
|
||||
atomic_add(&load_nfds, nfds);
|
||||
|
||||
/*
|
||||
* Process every DCB that has a new event and add
|
||||
* it to the poll queue.
|
||||
* If the DCB is currently beign processed then we
|
||||
* or in the new eent bits to the pending event bits
|
||||
* and leave it in the queue.
|
||||
* If the DCB was not already in the queue then it was
|
||||
* idle and is added to the queue to process after
|
||||
* setting the event bits.
|
||||
*/
|
||||
for (i = 0; i < nfds; i++)
|
||||
{
|
||||
DCB *dcb = (DCB *)events[i].data.ptr;
|
||||
__uint32_t ev = events[i].events;
|
||||
|
||||
CHK_DCB(dcb);
|
||||
if (thread_data)
|
||||
spinlock_acquire(&pollqlock);
|
||||
if (DCB_POLL_BUSY(dcb))
|
||||
{
|
||||
thread_data[thread_id].cur_dcb = dcb;
|
||||
thread_data[thread_id].event = ev;
|
||||
dcb->evq.pending_events |= ev;
|
||||
}
|
||||
|
||||
#if defined(SS_DEBUG)
|
||||
if (dcb_fake_write_ev[dcb->fd] != 0) {
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"Added fake events %d to ev %d.",
|
||||
pthread_self(),
|
||||
dcb_fake_write_ev[dcb->fd],
|
||||
ev)));
|
||||
ev |= dcb_fake_write_ev[dcb->fd];
|
||||
dcb_fake_write_ev[dcb->fd] = 0;
|
||||
}
|
||||
#endif
|
||||
ss_debug(spinlock_acquire(&dcb->dcb_initlock);)
|
||||
ss_dassert(dcb->state != DCB_STATE_ALLOC);
|
||||
ss_dassert(dcb->state != DCB_STATE_DISCONNECTED);
|
||||
ss_dassert(dcb->state != DCB_STATE_FREED);
|
||||
ss_debug(spinlock_release(&dcb->dcb_initlock);)
|
||||
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] event %d dcb %p "
|
||||
"role %s",
|
||||
pthread_self(),
|
||||
ev,
|
||||
dcb,
|
||||
STRDCBROLE(dcb->dcb_role))));
|
||||
|
||||
if (ev & EPOLLOUT)
|
||||
else
|
||||
{
|
||||
int eno = 0;
|
||||
eno = gw_getsockerrno(dcb->fd);
|
||||
|
||||
if (eno == 0) {
|
||||
#if MUTEX_BLOCK
|
||||
simple_mutex_lock(
|
||||
&dcb->dcb_write_lock,
|
||||
true);
|
||||
ss_info_dassert(
|
||||
!dcb->dcb_write_active,
|
||||
"Write already active");
|
||||
dcb->dcb_write_active = TRUE;
|
||||
atomic_add(
|
||||
&pollStats.n_write,
|
||||
1);
|
||||
dcb->func.write_ready(dcb);
|
||||
dcb->dcb_write_active = FALSE;
|
||||
simple_mutex_unlock(
|
||||
&dcb->dcb_write_lock);
|
||||
#else
|
||||
atomic_add(&pollStats.n_write,
|
||||
1);
|
||||
dcb_pollout(dcb, thread_id, nfds);
|
||||
#endif
|
||||
} else {
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"EPOLLOUT due %d, %s. "
|
||||
"dcb %p, fd %i",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno),
|
||||
dcb,
|
||||
dcb->fd)));
|
||||
}
|
||||
}
|
||||
if (ev & EPOLLIN)
|
||||
{
|
||||
#if MUTEX_BLOCK
|
||||
simple_mutex_lock(&dcb->dcb_read_lock,
|
||||
true);
|
||||
ss_info_dassert(!dcb->dcb_read_active,
|
||||
"Read already active");
|
||||
dcb->dcb_read_active = TRUE;
|
||||
#endif
|
||||
|
||||
if (dcb->state == DCB_STATE_LISTENING)
|
||||
dcb->evq.pending_events = ev;
|
||||
if (eventq)
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"Accept in fd %d",
|
||||
pthread_self(),
|
||||
dcb->fd)));
|
||||
atomic_add(
|
||||
&pollStats.n_accept, 1);
|
||||
dcb->func.accept(dcb);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"Read in dcb %p fd %d",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
dcb->fd)));
|
||||
atomic_add(&pollStats.n_read, 1);
|
||||
#if MUTEX_BLOCK
|
||||
dcb->func.read(dcb);
|
||||
#else
|
||||
dcb_pollin(dcb, thread_id, nfds);
|
||||
#endif
|
||||
}
|
||||
#if MUTEX_BLOCK
|
||||
dcb->dcb_read_active = FALSE;
|
||||
simple_mutex_unlock(
|
||||
&dcb->dcb_read_lock);
|
||||
#endif
|
||||
}
|
||||
if (ev & EPOLLERR)
|
||||
{
|
||||
int eno = gw_getsockerrno(dcb->fd);
|
||||
#if defined(SS_DEBUG)
|
||||
if (eno == 0) {
|
||||
eno = dcb_fake_write_errno[dcb->fd];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"Added fake errno %d. "
|
||||
"%s",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
}
|
||||
dcb_fake_write_errno[dcb->fd] = 0;
|
||||
#endif
|
||||
if (eno != 0) {
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"EPOLLERR due %d, %s.",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
}
|
||||
atomic_add(&pollStats.n_error, 1);
|
||||
dcb->func.error(dcb);
|
||||
}
|
||||
|
||||
if (ev & EPOLLHUP)
|
||||
{
|
||||
int eno = 0;
|
||||
eno = gw_getsockerrno(dcb->fd);
|
||||
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"EPOLLHUP on dcb %p, fd %d. "
|
||||
"Errno %d, %s.",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
dcb->fd,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
atomic_add(&pollStats.n_hup, 1);
|
||||
spinlock_acquire(&dcb->dcb_initlock);
|
||||
if ((dcb->flags & DCBF_HUNG) == 0)
|
||||
{
|
||||
dcb->flags |= DCBF_HUNG;
|
||||
spinlock_release(&dcb->dcb_initlock);
|
||||
dcb->func.hangup(dcb);
|
||||
dcb->evq.prev = eventq->evq.prev;
|
||||
eventq->evq.prev->evq.next = dcb;
|
||||
eventq->evq.prev = dcb;
|
||||
dcb->evq.next = eventq;
|
||||
}
|
||||
else
|
||||
spinlock_release(&dcb->dcb_initlock);
|
||||
}
|
||||
|
||||
#ifdef EPOLLRDHUP
|
||||
if (ev & EPOLLRDHUP)
|
||||
{
|
||||
int eno = 0;
|
||||
eno = gw_getsockerrno(dcb->fd);
|
||||
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"EPOLLRDHUP on dcb %p, fd %d. "
|
||||
"Errno %d, %s.",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
dcb->fd,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
atomic_add(&pollStats.n_hup, 1);
|
||||
spinlock_acquire(&dcb->dcb_initlock);
|
||||
if ((dcb->flags & DCBF_HUNG) == 0)
|
||||
{
|
||||
dcb->flags |= DCBF_HUNG;
|
||||
spinlock_release(&dcb->dcb_initlock);
|
||||
dcb->func.hangup(dcb);
|
||||
eventq = dcb;
|
||||
dcb->evq.prev = dcb;
|
||||
dcb->evq.next = dcb;
|
||||
}
|
||||
pollStats.evq_length++;
|
||||
if (pollStats.evq_length > pollStats.evq_max)
|
||||
{
|
||||
pollStats.evq_max = pollStats.evq_length;
|
||||
}
|
||||
else
|
||||
spinlock_release(&dcb->dcb_initlock);
|
||||
}
|
||||
#endif
|
||||
} /*< for */
|
||||
no_op = FALSE;
|
||||
} /*< if (nfds > 0) */
|
||||
process_zombies:
|
||||
if (thread_data)
|
||||
{
|
||||
thread_data[thread_id].state = THREAD_ZPROCESSING;
|
||||
spinlock_release(&pollqlock);
|
||||
}
|
||||
}
|
||||
zombies = dcb_process_zombies(thread_id, NULL);
|
||||
|
||||
if (zombies == NULL) {
|
||||
process_zombies_only = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* If there was nothing to process then process the zombie queue
|
||||
*/
|
||||
if (process_pollq(thread_id) == 0)
|
||||
{
|
||||
if (thread_data)
|
||||
{
|
||||
thread_data[thread_id].state = THREAD_ZPROCESSING;
|
||||
}
|
||||
zombies = dcb_process_zombies(thread_id);
|
||||
}
|
||||
|
||||
if (do_shutdown)
|
||||
{
|
||||
/*<
|
||||
@ -701,6 +551,320 @@ process_zombies:
|
||||
} /*< while(1) */
|
||||
}
|
||||
|
||||
/**
|
||||
* Process of the queue of DCB's that have outstanding events
|
||||
*
|
||||
* The first event on the queue will be chosen to be executed by this thread,
|
||||
* all other events will be left on the queue and may be picked up by other
|
||||
* threads. When the processing is complete the thread will take the DCB off the
|
||||
* queue if there are no pending events that have arrived since the thread started
|
||||
* to process the DCB. If there are pending events the DCB will be moved to the
|
||||
* back of the queue so that other DCB's will have a share of the threads to
|
||||
* execute events for them.
|
||||
*
|
||||
* @param thread_id The thread ID of the calling thread
|
||||
* @return 0 if no DCB's have been processed
|
||||
*/
|
||||
static int
|
||||
process_pollq(int thread_id)
|
||||
{
|
||||
DCB *dcb;
|
||||
int found = 0;
|
||||
uint32_t ev;
|
||||
|
||||
spinlock_acquire(&pollqlock);
|
||||
if (eventq == NULL)
|
||||
{
|
||||
/* Nothing to process */
|
||||
spinlock_release(&pollqlock);
|
||||
return 0;
|
||||
}
|
||||
dcb = eventq;
|
||||
if (dcb->evq.next == dcb->evq.prev && dcb->evq.processing == 0)
|
||||
{
|
||||
found = 1;
|
||||
dcb->evq.processing = 1;
|
||||
}
|
||||
else if (dcb->evq.next == dcb->evq.prev)
|
||||
{
|
||||
/* Only item in queue is being processed */
|
||||
spinlock_release(&pollqlock);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
do {
|
||||
dcb = dcb->evq.next;
|
||||
} while (dcb != eventq && dcb->evq.processing == 1);
|
||||
|
||||
if (dcb->evq.processing == 0)
|
||||
{
|
||||
/* Found DCB to process */
|
||||
dcb->evq.processing = 1;
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
ev = dcb->evq.pending_events;
|
||||
dcb->evq.pending_events = 0;
|
||||
}
|
||||
spinlock_release(&pollqlock);
|
||||
|
||||
if (found == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
CHK_DCB(dcb);
|
||||
if (thread_data)
|
||||
{
|
||||
thread_data[thread_id].state = THREAD_PROCESSING;
|
||||
thread_data[thread_id].cur_dcb = dcb;
|
||||
thread_data[thread_id].event = ev;
|
||||
}
|
||||
|
||||
#if defined(SS_DEBUG)
|
||||
if (dcb_fake_write_ev[dcb->fd] != 0) {
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"Added fake events %d to ev %d.",
|
||||
pthread_self(),
|
||||
dcb_fake_write_ev[dcb->fd],
|
||||
ev)));
|
||||
ev |= dcb_fake_write_ev[dcb->fd];
|
||||
dcb_fake_write_ev[dcb->fd] = 0;
|
||||
}
|
||||
#endif
|
||||
ss_debug(spinlock_acquire(&dcb->dcb_initlock);)
|
||||
ss_dassert(dcb->state != DCB_STATE_ALLOC);
|
||||
ss_dassert(dcb->state != DCB_STATE_DISCONNECTED);
|
||||
ss_dassert(dcb->state != DCB_STATE_FREED);
|
||||
ss_debug(spinlock_release(&dcb->dcb_initlock);)
|
||||
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] event %d dcb %p "
|
||||
"role %s",
|
||||
pthread_self(),
|
||||
ev,
|
||||
dcb,
|
||||
STRDCBROLE(dcb->dcb_role))));
|
||||
|
||||
if (ev & EPOLLOUT)
|
||||
{
|
||||
int eno = 0;
|
||||
eno = gw_getsockerrno(dcb->fd);
|
||||
|
||||
if (eno == 0) {
|
||||
#if MUTEX_BLOCK
|
||||
simple_mutex_lock(
|
||||
&dcb->dcb_write_lock,
|
||||
true);
|
||||
ss_info_dassert(
|
||||
!dcb->dcb_write_active,
|
||||
"Write already active");
|
||||
dcb->dcb_write_active = TRUE;
|
||||
atomic_add(
|
||||
&pollStats.n_write,
|
||||
1);
|
||||
dcb->func.write_ready(dcb);
|
||||
dcb->dcb_write_active = FALSE;
|
||||
simple_mutex_unlock(
|
||||
&dcb->dcb_write_lock);
|
||||
#else
|
||||
atomic_add(&pollStats.n_write,
|
||||
1);
|
||||
dcb->func.write_ready(dcb);
|
||||
#endif
|
||||
} else {
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"EPOLLOUT due %d, %s. "
|
||||
"dcb %p, fd %i",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno),
|
||||
dcb,
|
||||
dcb->fd)));
|
||||
}
|
||||
}
|
||||
if (ev & EPOLLIN)
|
||||
{
|
||||
#if MUTEX_BLOCK
|
||||
simple_mutex_lock(&dcb->dcb_read_lock,
|
||||
true);
|
||||
ss_info_dassert(!dcb->dcb_read_active,
|
||||
"Read already active");
|
||||
dcb->dcb_read_active = TRUE;
|
||||
#endif
|
||||
|
||||
if (dcb->state == DCB_STATE_LISTENING)
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"Accept in fd %d",
|
||||
pthread_self(),
|
||||
dcb->fd)));
|
||||
atomic_add(
|
||||
&pollStats.n_accept, 1);
|
||||
dcb->func.accept(dcb);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"Read in dcb %p fd %d",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
dcb->fd)));
|
||||
atomic_add(&pollStats.n_read, 1);
|
||||
dcb->func.read(dcb);
|
||||
}
|
||||
#if MUTEX_BLOCK
|
||||
dcb->dcb_read_active = FALSE;
|
||||
simple_mutex_unlock(
|
||||
&dcb->dcb_read_lock);
|
||||
#endif
|
||||
}
|
||||
if (ev & EPOLLERR)
|
||||
{
|
||||
int eno = gw_getsockerrno(dcb->fd);
|
||||
#if defined(SS_DEBUG)
|
||||
if (eno == 0) {
|
||||
eno = dcb_fake_write_errno[dcb->fd];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"Added fake errno %d. "
|
||||
"%s",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
}
|
||||
dcb_fake_write_errno[dcb->fd] = 0;
|
||||
#endif
|
||||
if (eno != 0) {
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"EPOLLERR due %d, %s.",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno))));
|
||||
}
|
||||
atomic_add(&pollStats.n_error, 1);
|
||||
dcb->func.error(dcb);
|
||||
}
|
||||
|
||||
if (ev & EPOLLHUP)
|
||||
{
|
||||
int eno = 0;
|
||||
eno = gw_getsockerrno(dcb->fd);
|
||||
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"EPOLLHUP on dcb %p, fd %d. "
|
||||
"Errno %d, %s.",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
dcb->fd,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
atomic_add(&pollStats.n_hup, 1);
|
||||
spinlock_acquire(&dcb->dcb_initlock);
|
||||
if ((dcb->flags & DCBF_HUNG) == 0)
|
||||
{
|
||||
dcb->flags |= DCBF_HUNG;
|
||||
spinlock_release(&dcb->dcb_initlock);
|
||||
dcb->func.hangup(dcb);
|
||||
}
|
||||
else
|
||||
spinlock_release(&dcb->dcb_initlock);
|
||||
}
|
||||
|
||||
#ifdef EPOLLRDHUP
|
||||
if (ev & EPOLLRDHUP)
|
||||
{
|
||||
int eno = 0;
|
||||
eno = gw_getsockerrno(dcb->fd);
|
||||
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
"EPOLLRDHUP on dcb %p, fd %d. "
|
||||
"Errno %d, %s.",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
dcb->fd,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
atomic_add(&pollStats.n_hup, 1);
|
||||
spinlock_acquire(&dcb->dcb_initlock);
|
||||
if ((dcb->flags & DCBF_HUNG) == 0)
|
||||
{
|
||||
dcb->flags |= DCBF_HUNG;
|
||||
spinlock_release(&dcb->dcb_initlock);
|
||||
dcb->func.hangup(dcb);
|
||||
}
|
||||
else
|
||||
spinlock_release(&dcb->dcb_initlock);
|
||||
}
|
||||
#endif
|
||||
|
||||
spinlock_acquire(&pollqlock);
|
||||
if (dcb->evq.pending_events == 0)
|
||||
{
|
||||
/* No pending events so remove from the queue */
|
||||
if (dcb->evq.prev != dcb)
|
||||
{
|
||||
dcb->evq.prev->evq.next = dcb->evq.next;
|
||||
dcb->evq.next->evq.prev = dcb->evq.prev;
|
||||
if (eventq == dcb)
|
||||
eventq = dcb->evq.next;
|
||||
}
|
||||
else
|
||||
{
|
||||
eventq = NULL;
|
||||
}
|
||||
dcb->evq.next = NULL;
|
||||
dcb->evq.prev = NULL;
|
||||
pollStats.evq_length--;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* We have a pending event, move to the end of the queue
|
||||
* if there are any other DCB's in the queue.
|
||||
*
|
||||
* If we are the first item on the queue this is easy, we
|
||||
* just bump the eventq pointer.
|
||||
*/
|
||||
if (dcb->evq.prev != dcb)
|
||||
{
|
||||
if (eventq == dcb)
|
||||
eventq = dcb->evq.next;
|
||||
else
|
||||
{
|
||||
dcb->evq.prev->evq.next = dcb->evq.next;
|
||||
dcb->evq.next->evq.prev = dcb->evq.prev;
|
||||
dcb->evq.prev = eventq->evq.prev;
|
||||
dcb->evq.next = eventq;
|
||||
eventq->evq.prev = dcb;
|
||||
dcb->evq.prev->evq.next = dcb;
|
||||
}
|
||||
}
|
||||
}
|
||||
dcb->evq.processing = 0;
|
||||
spinlock_release(&pollqlock);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown the polling loop
|
||||
*/
|
||||
@ -721,6 +885,20 @@ poll_bitmask()
|
||||
return &poll_mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display an entry from the spinlock statistics data
|
||||
*
|
||||
* @param dcb The DCB to print to
|
||||
* @param desc Description of the statistic
|
||||
* @param value The statistic value
|
||||
*/
|
||||
static void
|
||||
spin_reporter(void *dcb, char *desc, int value)
|
||||
{
|
||||
dcb_printf((DCB *)dcb, "\t%-40s %d\n", desc, value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Debug routine to print the polling statistics
|
||||
*
|
||||
@ -745,6 +923,10 @@ int i;
|
||||
pollStats.n_accept);
|
||||
dcb_printf(dcb, "Number of times no threads polling: %d\n",
|
||||
pollStats.n_nothreads);
|
||||
dcb_printf(dcb, "Current event queue length: %d\n",
|
||||
pollStats.evq_length);
|
||||
dcb_printf(dcb, "Maximum event queue length: %d\n",
|
||||
pollStats.evq_max);
|
||||
|
||||
dcb_printf(dcb, "No of poll completions with descriptors\n");
|
||||
dcb_printf(dcb, "\tNo. of descriptors\tNo. of poll completions.\n");
|
||||
@ -754,6 +936,11 @@ int i;
|
||||
}
|
||||
dcb_printf(dcb, "\t>= %d\t\t\t%d\n", MAXNFDS,
|
||||
pollStats.n_fds[MAXNFDS-1]);
|
||||
|
||||
#if SPINLOCK_PROFILE
|
||||
dcb_printf(dcb, "Event queue lock statistics:\n");
|
||||
spinlock_stats(&pollqlock, spin_reporter, dcb);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
#include <secrets.h>
|
||||
@ -74,16 +74,29 @@ int len;
|
||||
snprintf(secret_file, 255, "%s/etc/.secrets", home);
|
||||
|
||||
/* Try to access secrets file */
|
||||
if (access(secret_file, R_OK) == -1) {
|
||||
if (access(secret_file, R_OK) == -1)
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : access for secrets file "
|
||||
"[%s] failed. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
if (eno == ENOENT)
|
||||
{
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE,
|
||||
"Encrypted password file %s can't be accessed "
|
||||
"(%s). Password encryption is not used.",
|
||||
secret_file,
|
||||
strerror(eno))));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : access for secrets file "
|
||||
"[%s] failed. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -13,11 +13,11 @@
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright SkySQL Ab 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file spinlock.c - Spinlock operations for the SkySQL Gateway
|
||||
* @file spinlock.c - Spinlock operations for the MariaDB Corporation MaxScale
|
||||
*
|
||||
* @verbatim
|
||||
* Revision History
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
#include <thread.h>
|
||||
#include <pthread.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*
|
||||
*/
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
* 10-06-2013 Massimiliano Pinto Initial implementation
|
||||
* 12-06-2013 Massimiliano Pinto Read function trought
|
||||
* the gwbuff strategy
|
||||
* 13-06-2013 Massimiliano Pinto Gateway local authentication
|
||||
* 13-06-2013 Massimiliano Pinto MaxScale local authentication
|
||||
* basics
|
||||
*
|
||||
* @endverbatim
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _ADMINUSERS_H
|
||||
#define _ADMINUSERS_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _ATOMIC_H
|
||||
#define _ATOMIC_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _BUFFER_H
|
||||
#define _BUFFER_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -47,6 +47,7 @@
|
||||
#include <skygw_debug.h>
|
||||
#include <hint.h>
|
||||
#include <spinlock.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
EXTERN_C_BLOCK_BEGIN
|
||||
@ -150,15 +151,15 @@ typedef struct gwbuf {
|
||||
#define GWBUF_DATA(b) ((b)->start)
|
||||
|
||||
/*< Number of bytes in the individual buffer */
|
||||
#define GWBUF_LENGTH(b) ((b)->end - (b)->start)
|
||||
#define GWBUF_LENGTH(b) ((unsigned int)(((uint8_t*)(b)->end) - ((uint8_t*)(b)->start)))
|
||||
|
||||
/*< True if all bytes in the buffer have been consumed */
|
||||
#define GWBUF_EMPTY(b) ((b)->start == (b)->end)
|
||||
|
||||
/*< Consume a number of bytes in the buffer */
|
||||
#define GWBUF_CONSUME(b, bytes) (b)->start += (bytes)
|
||||
#define GWBUF_CONSUME(b, bytes) (b)->start = (void*)((uint8_t*)(b)->start + (bytes))
|
||||
|
||||
#define GWBUF_RTRIM(b, bytes) (b)->end -= (bytes)
|
||||
#define GWBUF_RTRIM(b, bytes) (b)->end = (void*)((uint8_t*)(b)->end - (bytes))
|
||||
|
||||
#define GWBUF_TYPE(b) (b)->gwbuf_type
|
||||
/*<
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _CONFIG_H
|
||||
#define _CONFIG_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
#include <skygw_utils.h>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _DBUSERS_H
|
||||
#define _DBUSERS_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
#include <service.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _DCB_H
|
||||
#define _DCB_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
#include <spinlock.h>
|
||||
#include <buffer.h>
|
||||
@ -53,7 +53,8 @@ struct service;
|
||||
* 07/02/2014 Massimiliano Pinto Added ipv4 data struct into for dcb
|
||||
* 07/05/2014 Mark Riddoch Addition of callback mechanism
|
||||
* 08/05/2014 Mark Riddoch Addition of writeq high and low watermarks
|
||||
* 27/08/2014 Mark Ridddoch Addition of write event queuing
|
||||
* 27/08/2014 Mark Riddoch Addition of write event queuing
|
||||
* 23/09/2014 Mark Riddoch New poll processing queue
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
@ -65,7 +66,7 @@ struct dcb;
|
||||
* The operations that can be performed on the descriptor
|
||||
*
|
||||
* read EPOLLIN handler for the socket
|
||||
* write Gateway data write entry point
|
||||
* write MaxScale data write entry point
|
||||
* write_ready EPOLLOUT handler for the socket, indicates
|
||||
* that the socket is ready to send more data
|
||||
* error EPOLLERR handler for the socket
|
||||
@ -73,7 +74,7 @@ struct dcb;
|
||||
* accept Accept handler for listener socket only
|
||||
* connect Create a connection to the specified server
|
||||
* for the session pased in
|
||||
* close Gateway close entry point for the socket
|
||||
* close MaxScale close entry point for the socket
|
||||
* listen Create a listener for the protocol
|
||||
* auth Authentication entry point
|
||||
* session Session handling entry point
|
||||
@ -97,6 +98,14 @@ typedef struct gw_protocol {
|
||||
int (*session)(struct dcb *, void *);
|
||||
} GWPROTOCOL;
|
||||
|
||||
typedef struct {
|
||||
struct dcb *next;
|
||||
struct dcb *prev;
|
||||
uint32_t pending_events;
|
||||
int processing;
|
||||
SPINLOCK eventqlock;
|
||||
} DCBEVENTQ;
|
||||
|
||||
/**
|
||||
* The GWPROTOCOL version data. The following should be updated whenever
|
||||
* the GWPROTOCOL structure is changed. See the rules defined in modinfo.h
|
||||
@ -114,10 +123,6 @@ typedef struct dcbstats {
|
||||
int n_buffered; /*< Number of buffered writes */
|
||||
int n_high_water; /*< Number of crosses of high water mark */
|
||||
int n_low_water; /*< Number of crosses of low water mark */
|
||||
int n_busypolls; /*< Number of read polls whiel reading */
|
||||
int n_readrechecks; /*< Number of rechecks for reads */
|
||||
int n_busywrpolls; /*< Number of write polls while writing */
|
||||
int n_writerechecks;/*< Number of rechecks for writes */
|
||||
} DCBSTATS;
|
||||
|
||||
/**
|
||||
@ -204,12 +209,7 @@ typedef struct dcb {
|
||||
#endif
|
||||
dcb_role_t dcb_role;
|
||||
SPINLOCK dcb_initlock;
|
||||
#if 1
|
||||
simple_mutex_t dcb_read_lock;
|
||||
simple_mutex_t dcb_write_lock;
|
||||
bool dcb_read_active;
|
||||
bool dcb_write_active;
|
||||
#endif
|
||||
DCBEVENTQ evq; /**< The event queue for this DCB */
|
||||
int fd; /**< The descriptor */
|
||||
dcb_state_t state; /**< Current descriptor state */
|
||||
int flags; /**< DCB flags */
|
||||
@ -271,8 +271,8 @@ int fail_accept_errno;
|
||||
#define DCB_BELOW_LOW_WATER(x) ((x)->low_water && (x)->writeqlen < (x)->low_water)
|
||||
#define DCB_ABOVE_HIGH_WATER(x) ((x)->high_water && (x)->writeqlen > (x)->high_water)
|
||||
|
||||
void dcb_pollin(DCB *, int, int);
|
||||
void dcb_pollout(DCB *, int, int);
|
||||
#define DCB_POLL_BUSY(x) ((x)->evq.next != NULL)
|
||||
|
||||
DCB *dcb_get_zombies(void);
|
||||
int gw_write(
|
||||
#if defined(SS_DEBUG)
|
||||
@ -289,7 +289,7 @@ DCB *dcb_clone(DCB *);
|
||||
int dcb_read(DCB *, GWBUF **);
|
||||
int dcb_drain_writeq(DCB *);
|
||||
void dcb_close(DCB *);
|
||||
DCB *dcb_process_zombies(int, DCB*); /* Process Zombies except the one behind the pointer */
|
||||
DCB *dcb_process_zombies(int); /* Process Zombies except the one behind the pointer */
|
||||
void printAllDCBs(); /* Debug to print all DCB in the system */
|
||||
void printDCB(DCB *); /* Debug print routine */
|
||||
void dprintAllDCBs(DCB *); /* Debug to print all DCB in the system */
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _FILTER_H
|
||||
#define _FILTER_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -28,10 +28,10 @@
|
||||
* Configuration for send and receive socket buffer sizes for
|
||||
* backend and cleint connections.
|
||||
*/
|
||||
#define GW_BACKEND_SO_SNDBUF 32768
|
||||
#define GW_BACKEND_SO_RCVBUF 32768
|
||||
#define GW_CLIENT_SO_SNDBUF 32768
|
||||
#define GW_CLIENT_SO_RCVBUF 32768
|
||||
#define GW_BACKEND_SO_SNDBUF (128 * 1024)
|
||||
#define GW_BACKEND_SO_RCVBUF (128 * 1024)
|
||||
#define GW_CLIENT_SO_SNDBUF (128 * 1024)
|
||||
#define GW_CLIENT_SO_RCVBUF (128 * 1024)
|
||||
|
||||
#define GW_NOINTR_CALL(A) do { errno = 0; A; } while (errno == EINTR)
|
||||
#define GW_MYSQL_LOOP_TIMEOUT 300000000
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _GWBITMASK_H
|
||||
#define _GWBITMASK_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
#include <spinlock.h>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _HASTABLE_H
|
||||
#define _HASTABLE_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -15,7 +15,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
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _HOUSEKEEPER_H
|
||||
#define _HOUSEKEEPER_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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 <time.h>
|
||||
|
||||
@ -47,4 +47,5 @@ typedef struct hktask {
|
||||
extern void hkinit();
|
||||
extern int hktask_add(char *name, void (*task)(void *), void *data, int frequency);
|
||||
extern int hktask_remove(char *name);
|
||||
extern void hkshutdown();
|
||||
#endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _MAXSCALE_H
|
||||
#define _MAXSCALE_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -15,7 +15,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
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _MODULES_H
|
||||
#define _MODULES_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
#include <dcb.h>
|
||||
#include <modinfo.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _MODUTIL_H
|
||||
#define _MODUTIL_H
|
||||
/*
|
||||
* This file is distributed as part of MaxScale from SkySQL. It is free
|
||||
* This file is distributed as part of MaxScale from 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.
|
||||
@ -15,7 +15,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
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _MONITOR_H
|
||||
#define _MONITOR_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
#include <server.h>
|
||||
#include <dcb.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef _POLL_H
|
||||
#define _POLL_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
#include <dcb.h>
|
||||
#include <gwbitmask.h>
|
||||
|
61
server/include/rdtsc.h
Normal file
61
server/include/rdtsc.h
Normal file
@ -0,0 +1,61 @@
|
||||
#ifndef _RDTSC_H
|
||||
#define _RDTSC_H
|
||||
/*
|
||||
* This file is distributed as part of the MariaDB Corporation 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file rdtsc.h Access the process time-stamp counter
|
||||
*
|
||||
* This is an Intel only facilty that is used to access an accurate time
|
||||
* value, the granularity of which is related to the processor clock speed
|
||||
* and the overhead for access is much lower than using any system call
|
||||
* mechanism.
|
||||
*
|
||||
*
|
||||
* @verbatim
|
||||
* Revision History
|
||||
*
|
||||
* Date Who Description
|
||||
* 19/09/2014 Mark Riddoch Initial implementation
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
|
||||
typedef unsigned long long CYCLES;
|
||||
|
||||
/**
|
||||
* Get the current time-stamp counter value from the processor. This is the
|
||||
* count of CPU cyceles as a 64 bit value.
|
||||
*
|
||||
* The value returned is related to the clock speed, to obtian a value in
|
||||
* seconds divide the returned value by the clock frequency for the processor.
|
||||
*
|
||||
* Note, on multi-processsor systems care much be taken to avoid the thread
|
||||
* moving to a different processor when taken succsive value of RDTSC to
|
||||
* obtian accurate timing. This may be done by setting pocessor affinity for
|
||||
* the thread. See sched_setaffinity/sched_getaffinity.
|
||||
*
|
||||
* @return CPU cycle count
|
||||
*/
|
||||
static __inline__ CYCLES rdtsc(void)
|
||||
{
|
||||
unsigned long long int x;
|
||||
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
|
||||
return x;
|
||||
}
|
||||
#endif
|
@ -1,7 +1,7 @@
|
||||
#ifndef _ROUTER_H
|
||||
#define _ROUTER_H
|
||||
/*
|
||||
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||
* This file is distributed as part of the MariaDB Corporation 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.
|
||||
@ -15,7 +15,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 2013
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
/**
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user