Merge from develop

Merge from develop
This commit is contained in:
MassimilianoPinto
2014-10-20 09:03:11 +02:00
8 changed files with 98 additions and 43 deletions

View File

@ -15,10 +15,11 @@ check_dirs()
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/modules) 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) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/server/include)
configure_file(${CMAKE_SOURCE_DIR}/maxscale.conf.in ${CMAKE_SOURCE_DIR}/maxscale.conf.prep @ONLY) configure_file(${CMAKE_SOURCE_DIR}/server/include/version.h.in ${CMAKE_BINARY_DIR}/server/include/version.h)
configure_file(${CMAKE_SOURCE_DIR}/etc/init.d/maxscale.in ${CMAKE_SOURCE_DIR}/etc/init.d/maxscale.prep @ONLY) configure_file(${CMAKE_SOURCE_DIR}/maxscale.conf.in ${CMAKE_BINARY_DIR}/maxscale.conf.prep @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/etc/ubuntu/init.d/maxscale.in ${CMAKE_SOURCE_DIR}/etc/ubuntu/init.d/maxscale.prep @ONLY) configure_file(${CMAKE_SOURCE_DIR}/etc/init.d/maxscale.in ${CMAKE_BINARY_DIR}/etc/init.d/maxscale.prep @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/etc/ubuntu/init.d/maxscale.in ${CMAKE_BINARY_DIR}/etc/ubuntu/init.d/maxscale.prep @ONLY)
set(CMAKE_C_FLAGS "-Wall -fPIC") set(CMAKE_C_FLAGS "-Wall -fPIC")
@ -71,6 +72,7 @@ include_directories(query_classifier)
include_directories(server/include) include_directories(server/include)
include_directories(server/inih) include_directories(server/inih)
include_directories(server/modules/include) include_directories(server/modules/include)
include_directories(${CMAKE_BINARY_DIR}/server/include)
add_subdirectory(utils) add_subdirectory(utils)
add_subdirectory(log_manager) add_subdirectory(log_manager)
@ -82,11 +84,11 @@ add_subdirectory(client)
# Install startup scripts and ldconfig files # Install startup scripts and ldconfig files
if( NOT ( (DEFINED INSTALL_SYSTEM_FILES) AND ( NOT ( INSTALL_SYSTEM_FILES ) ) ) ) if( NOT ( (DEFINED INSTALL_SYSTEM_FILES) AND ( NOT ( INSTALL_SYSTEM_FILES ) ) ) )
install(FILES maxscale.conf.prep RENAME maxscale.conf DESTINATION /etc/ld.so.conf.d/ PERMISSIONS WORLD_EXECUTE WORLD_READ) install(FILES ${CMAKE_BINARY_DIR}/maxscale.conf.prep RENAME maxscale.conf DESTINATION /etc/ld.so.conf.d/ PERMISSIONS WORLD_EXECUTE WORLD_READ)
if(DEB_BASED) if(DEB_BASED)
install(FILES etc/ubuntu/init.d/maxscale.prep RENAME maxscale DESTINATION /etc/init.d/ PERMISSIONS WORLD_EXECUTE) install(FILES ${CMAKE_BINARY_DIR}/etc/ubuntu/init.d/maxscale.prep RENAME maxscale DESTINATION /etc/init.d/ PERMISSIONS WORLD_EXECUTE)
else() else()
install(FILES etc/init.d/maxscale.prep RENAME maxscale DESTINATION /etc/init.d/ PERMISSIONS WORLD_EXECUTE) install(FILES ${CMAKE_BINARY_DIR}/etc/init.d/maxscale.prep RENAME maxscale DESTINATION /etc/init.d/ PERMISSIONS WORLD_EXECUTE)
endif() endif()
message(STATUS "Installing maxscale.conf to: /etc/ld.so.conf.d") message(STATUS "Installing maxscale.conf to: /etc/ld.so.conf.d")
message(STATUS "Installing startup scripts to: /etc/init.d") message(STATUS "Installing startup scripts to: /etc/init.d")
@ -148,4 +150,14 @@ add_custom_target(testall
COMMAND /bin/sh -c "${CMAKE_BINARY_DIR}/bin/maxscale -c ${CMAKE_BINARY_DIR} &>/dev/null" 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 /bin/sh -c "make test || echo \"Test results written to: ${CMAKE_BINARY_DIR}/Testing/Temporary/\""
COMMAND killall maxscale COMMAND killall maxscale
COMMENT "Running full test suite..." VERBATIM) COMMENT "Running full test suite..." VERBATIM)
# uninstall target
# see http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)

24
cmake_uninstall.cmake.in Normal file
View File

@ -0,0 +1,24 @@
# "make uninstall" helper
# see http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)

View File

@ -29,23 +29,32 @@
*/ */
/** /**
* Implementation of an atomic add operation for the X86 processor. * Implementation of an atomic add operation for the GCC environment, or the
* X86 processor. If we are working within GNU C then we can use the GCC
* atomic add built in function, which is portable across platforms that
* implement GCC. Otherwise, this function currently supports only X86
* architecture (without further development).
*
* Adds a value to the contents of a location pointed to by the first parameter. * Adds a value to the contents of a location pointed to by the first parameter.
* The add operation is atomic and the return value is the value stored in the location * The add operation is atomic and the return value is the value stored in the
* prior to the operation. The number that is added may be signed, therefore atomic_subtract * location prior to the operation. The number that is added may be signed,
* is merely an atomic add with a negative value. * therefore atomic_subtract is merely an atomic add with a negative value.
* *
* @param variable Pointer the the variable to add to * @param variable Pointer the the variable to add to
* @param value Value to be added * @param value Value to be added
* @return Pointer to the value of variable before the add occured * @return The value of variable before the add occurred
*/ */
int int
atomic_add(int *variable, int value) atomic_add(int *variable, int value)
{ {
#ifdef __GNUC__
return (int) __sync_fetch_and_add (variable, value);
#else
asm volatile( asm volatile(
"lock; xaddl %%eax, %2;" "lock; xaddl %%eax, %2;"
:"=a" (value) :"=a" (value)
: "a" (value), "m" (*variable) : "a" (value), "m" (*variable)
: "memory" ); : "memory" );
return value; return value;
#endif
} }

View File

@ -162,7 +162,7 @@ SERVER *server;
server = allServers; server = allServers;
while (server) while (server)
{ {
if (strcmp(server->unique_name, name) == 0) if (server->unique_name && strcmp(server->unique_name, name) == 0)
break; break;
server = server->next; server = server->next;
} }

View File

@ -63,13 +63,14 @@ char *status;
ss_info_dassert(server == server_find_by_unique_name("uniquename"), "Should find by unique name."); ss_info_dassert(server == server_find_by_unique_name("uniquename"), "Should find by unique name.");
ss_dfprintf(stderr, "\t..done\nTesting Status Setting for Server."); ss_dfprintf(stderr, "\t..done\nTesting Status Setting for Server.");
status = server_status(server); status = server_status(server);
ss_info_dassert(0 == strcmp("Down", status), "Status of Server should be Down prior to being set."); ss_info_dassert(0 == strcmp("Running", status), "Status of Server should be Running by default.");
if (NULL != status) free(status); if (NULL != status) free(status);
server_set_status(server, SERVER_MASTER); server_set_status(server, SERVER_MASTER);
status = server_status(server); status = server_status(server);
ss_info_dassert(0 == strcmp("Master, Down", status), "Should find correct status."); ss_info_dassert(0 == strcmp("Master, Running", status), "Should find correct status.");
server_clear_status(server, SERVER_MASTER); server_clear_status(server, SERVER_MASTER);
ss_info_dassert(0 == strcmp("Down", status), "Status of Server should be Down after status cleared."); status = server_status(server);
ss_info_dassert(0 == strcmp("Running", status), "Status of Server should be Running after master status cleared.");
if (NULL != status) free(status); if (NULL != status) free(status);
ss_dfprintf(stderr, "\t..done\nRun Prints for Server and all Servers."); ss_dfprintf(stderr, "\t..done\nRun Prints for Server and all Servers.");
printServer(server); printServer(server);

View File

@ -41,7 +41,8 @@
static int static int
test1() test1()
{ {
USERS *users; USERS *users;
char *authdata;
int result, count; int result, count;
/* Poll tests */ /* Poll tests */
@ -52,13 +53,17 @@ int result, count;
ss_dfprintf(stderr, "\t..done\nAdd a user"); ss_dfprintf(stderr, "\t..done\nAdd a user");
count = users_add(users, "username", "authorisation"); count = users_add(users, "username", "authorisation");
ss_info_dassert(1 == count, "Should add one user"); ss_info_dassert(1 == count, "Should add one user");
ss_info_dassert(strcmp("authorisation", users_fetch(users, "username")), "User authorisation should be correct"); authdata = users_fetch(users, "username");
ss_info_dassert(NULL != authdata, "Fetch valid user must not return NULL");
ss_info_dassert(0 == strcmp("authorisation", authdata), "User authorisation should be correct");
ss_dfprintf(stderr, "\t..done\nPrint users"); ss_dfprintf(stderr, "\t..done\nPrint users");
usersPrint(users); usersPrint(users);
ss_dfprintf(stderr, "\t..done\nUpdate a user"); ss_dfprintf(stderr, "\t..done\nUpdate a user");
count = users_update(users, "username", "newauth"); count = users_update(users, "username", "newauth");
ss_info_dassert(1 == count, "Should update just one user"); ss_info_dassert(1 == count, "Should update just one user");
ss_info_dassert(strcmp("newauth", users_fetch(users, "username")), "User authorisation should be correctly updated"); authdata = users_fetch(users, "username");
ss_info_dassert(NULL != authdata, "Fetch valid user must not return NULL");
ss_info_dassert(0 == strcmp("newauth", authdata), "User authorisation should be correctly updated");
ss_dfprintf(stderr, "\t..done\nDelete a user."); ss_dfprintf(stderr, "\t..done\nDelete a user.");
count = users_delete(users, "username"); count = users_delete(users, "username");
ss_info_dassert(1 == count, "Should delete just one user"); ss_info_dassert(1 == count, "Should delete just one user");

View File

@ -1111,21 +1111,21 @@ int gw_send_change_user_to_backend(
// add the user // add the user
bytes += strlen(user); bytes += strlen(user);
// the NULL // NULL byte for user string
bytes++; bytes++;
// next will be + 1 (scramble_len) + 20 (fixed_scramble) + (dbname + NULL term) + 2 bytes charset // next will be + 1 (scramble_len) + 20 (fixed_scramble) + (dbname + NULL term) + 2 bytes charset
if (curr_passwd != NULL) { if (curr_passwd != NULL) {
bytes += GW_MYSQL_SCRAMBLE_SIZE; bytes += GW_MYSQL_SCRAMBLE_SIZE;
} }
// the NULL // 1 byte for scramble_len
bytes++; bytes++;
if (curr_db != NULL) { if (curr_db != NULL) {
bytes += strlen(curr_db); bytes += strlen(curr_db);
} }
// the NULL // NULL byte for dbname string
bytes++; bytes++;
// the charset // the charset

View File

@ -2696,34 +2696,38 @@ static bool select_connect_backend_servers(
switch(select_criteria) { switch(select_criteria) {
case LEAST_GLOBAL_CONNECTIONS: case LEAST_GLOBAL_CONNECTIONS:
LOGIF(LT, (skygw_log_write_flush(LOGFILE_TRACE, LOGIF(LT, (skygw_log_write_flush(LOGFILE_TRACE,
"%s:%d MaxScale connections : %d", "MaxScale connections : %d in \t%s:%d %s",
b->backend_server->name, b->backend_server->stats.n_current,
b->backend_server->port, b->backend_server->name,
b->backend_server->stats.n_current))); b->backend_server->port,
STRSRVSTATUS(b->backend_server))));
break; break;
case LEAST_ROUTER_CONNECTIONS: case LEAST_ROUTER_CONNECTIONS:
LOGIF(LT, (skygw_log_write_flush(LOGFILE_TRACE, LOGIF(LT, (skygw_log_write_flush(LOGFILE_TRACE,
"%s:%d RWSplit connections : %d", "RWSplit connections : %d in \t%s:%d %s",
b->backend_server->name, b->backend_conn_count,
b->backend_server->port, b->backend_server->name,
b->backend_conn_count))); b->backend_server->port,
STRSRVSTATUS(b->backend_server))));
break; break;
case LEAST_CURRENT_OPERATIONS: case LEAST_CURRENT_OPERATIONS:
LOGIF(LT, (skygw_log_write_flush(LOGFILE_TRACE, LOGIF(LT, (skygw_log_write_flush(LOGFILE_TRACE,
"%s:%d current operations : %d", "current operations : %d in \t%s:%d %s",
b->backend_server->name, b->backend_server->stats.n_current_ops,
b->backend_server->port, b->backend_server->name,
b->backend_server->stats.n_current_ops))); b->backend_server->port,
STRSRVSTATUS(b->backend_server))));
break; break;
case LEAST_BEHIND_MASTER: case LEAST_BEHIND_MASTER:
LOGIF(LT, (skygw_log_write_flush(LOGFILE_TRACE, LOGIF(LT, (skygw_log_write_flush(LOGFILE_TRACE,
"%s:%d replication lag : %d", "replication lag : %d in \t%s:%d %s",
b->backend_server->name, b->backend_server->rlag,
b->backend_server->port, b->backend_server->name,
b->backend_server->rlag))); b->backend_server->port,
STRSRVSTATUS(b->backend_server))));
default: default:
break; break;
} }