Make query classifier self-contained.
Only the query classifier needs the functionality of the embedded server, while the rest of MaxScale is content with the client library or Connector/C. This have now been rearranged so that query-classifier links with the embedded static library and then explicitly exports its own functions using the query_classifier.map linker script. That way query classifier will use the embedded library, while the rest of maxscale use the client library, and this without conflicts. Currently, query_classifier is not linked to maxscale-common, but executables must link to maxscale-common and query_classifier.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
add_library(maxscale-common SHARED adminusers.c atomic.c buffer.c config.c dbusers.c dcb.c filter.c externcmd.c gwbitmask.c gwdirs.c gw_utils.c hashtable.c hint.c housekeeper.c load_utils.c maxscale_pcre2.c memlog.c modutil.c monitor.c poll.c random_jkiss.c resultset.c secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c ${CMAKE_SOURCE_DIR}/log_manager/log_manager.cc ${CMAKE_SOURCE_DIR}/utils/skygw_utils.cc)
|
||||
|
||||
target_link_libraries(maxscale-common ${EMBEDDED_LIB} ${LZMA_LINK_FLAGS} ${PCRE2_LIBRARIES} ${PCRE_LINK_FLAGS} ${CURL_LIBRARIES} ssl aio pthread crypt dl crypto inih z rt m stdc++)
|
||||
target_link_libraries(maxscale-common ${MYSQLCLIENT_LIBRARIES} ${LZMA_LINK_FLAGS} ${PCRE2_LIBRARIES} ${CURL_LIBRARIES} ssl aio pthread crypt dl crypto inih z rt m stdc++)
|
||||
|
||||
if(WITH_JEMALLOC)
|
||||
target_link_libraries(maxscale-common ${JEMALLOC_LIBRARIES})
|
||||
@ -20,15 +20,15 @@ elseif(WITH_TCMALLOC)
|
||||
target_link_libraries(maxscale ${TCMALLOC_LIBRARIES})
|
||||
endif()
|
||||
|
||||
target_link_libraries(maxscale maxscale-common)
|
||||
target_link_libraries(maxscale maxscale-common query_classifier)
|
||||
install(TARGETS maxscale DESTINATION ${MAXSCALE_BINDIR})
|
||||
|
||||
add_executable(maxkeys maxkeys.c)
|
||||
target_link_libraries(maxkeys maxscale-common)
|
||||
target_link_libraries(maxkeys maxscale-common query_classifier)
|
||||
install(TARGETS maxkeys DESTINATION ${MAXSCALE_BINDIR})
|
||||
|
||||
add_executable(maxpasswd maxpasswd.c)
|
||||
target_link_libraries(maxpasswd maxscale-common)
|
||||
target_link_libraries(maxpasswd maxscale-common query_classifier)
|
||||
install(TARGETS maxpasswd DESTINATION ${MAXSCALE_BINDIR})
|
||||
|
||||
if(BUILD_TESTS)
|
||||
|
@ -79,8 +79,9 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
# include <skygw_utils.h>
|
||||
# include <log_manager.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
#include <query_classifier.h>
|
||||
|
||||
#include <execinfo.h>
|
||||
|
||||
@ -990,17 +991,26 @@ static void usage(void)
|
||||
*/
|
||||
void worker_thread_main(void* arg)
|
||||
{
|
||||
/** Init mysql thread context for use with a mysql handle and a parser */
|
||||
if (mysql_thread_init() == 0)
|
||||
if (qc_thread_init())
|
||||
{
|
||||
poll_waitevents(arg);
|
||||
/** Init mysql thread context for use with a mysql handle and a parser */
|
||||
if (mysql_thread_init() == 0)
|
||||
{
|
||||
poll_waitevents(arg);
|
||||
|
||||
/** Release mysql thread context */
|
||||
mysql_thread_end();
|
||||
/** Release mysql thread context */
|
||||
mysql_thread_end();
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("Could not perform thread initialization for MySQL. Exiting thread.");
|
||||
}
|
||||
|
||||
qc_thread_end();
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("Could not perform thread initialization for MySQL. Exiting thread.");
|
||||
MXS_ERROR("Could not perform thread initialization for query classifier. Exiting thread.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1818,6 +1828,14 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (!qc_init(num_elements, server_options, server_groups))
|
||||
{
|
||||
char* logerr = "Failed to initialise query classifier library.";
|
||||
print_log_n_stderr(true, true, logerr, logerr, eno);
|
||||
rc = MAXSCALE_INTERNALERROR;
|
||||
goto return_main;
|
||||
}
|
||||
|
||||
if (mysql_library_init(num_elements, server_options, server_groups))
|
||||
{
|
||||
if (!daemon_mode)
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <mysql.h>
|
||||
#include <resultset.h>
|
||||
#include <session.h>
|
||||
#include <query_classifier.h>
|
||||
|
||||
#define PROFILE_POLL 0
|
||||
|
||||
|
@ -15,22 +15,22 @@ add_executable(test_users testusers.c)
|
||||
add_executable(testfeedback testfeedback.c)
|
||||
add_executable(testmaxscalepcre2 testmaxscalepcre2.c)
|
||||
add_executable(testmemlog testmemlog.c)
|
||||
target_link_libraries(test_adminusers maxscale-common)
|
||||
target_link_libraries(test_buffer maxscale-common)
|
||||
target_link_libraries(test_dcb maxscale-common)
|
||||
target_link_libraries(test_filter maxscale-common)
|
||||
target_link_libraries(test_hash maxscale-common )
|
||||
target_link_libraries(test_hint maxscale-common )
|
||||
target_link_libraries(test_modutil maxscale-common)
|
||||
target_link_libraries(test_mysql_users MySQLClient maxscale-common)
|
||||
target_link_libraries(test_poll maxscale-common)
|
||||
target_link_libraries(test_server maxscale-common)
|
||||
target_link_libraries(test_service maxscale-common)
|
||||
target_link_libraries(test_spinlock maxscale-common )
|
||||
target_link_libraries(test_users maxscale-common)
|
||||
target_link_libraries(testfeedback maxscale-common)
|
||||
target_link_libraries(testmaxscalepcre2 maxscale-common )
|
||||
target_link_libraries(testmemlog maxscale-common )
|
||||
target_link_libraries(test_adminusers maxscale-common query_classifier)
|
||||
target_link_libraries(test_buffer maxscale-common query_classifier)
|
||||
target_link_libraries(test_dcb maxscale-common query_classifier)
|
||||
target_link_libraries(test_filter maxscale-common query_classifier)
|
||||
target_link_libraries(test_hash maxscale-common query_classifier)
|
||||
target_link_libraries(test_hint maxscale-common query_classifier)
|
||||
target_link_libraries(test_modutil maxscale-common query_classifier)
|
||||
target_link_libraries(test_mysql_users MySQLClient maxscale-common query_classifier)
|
||||
target_link_libraries(test_poll maxscale-common query_classifier)
|
||||
target_link_libraries(test_server maxscale-common query_classifier)
|
||||
target_link_libraries(test_service maxscale-common query_classifier)
|
||||
target_link_libraries(test_spinlock maxscale-common query_classifier)
|
||||
target_link_libraries(test_users maxscale-common query_classifier)
|
||||
target_link_libraries(testfeedback maxscale-common query_classifier)
|
||||
target_link_libraries(testmaxscalepcre2 maxscale-common query_classifier)
|
||||
target_link_libraries(testmemlog maxscale-common query_classifier)
|
||||
add_test(Internal-TestAdminUsers test_adminusers)
|
||||
add_test(Internal-TestBuffer test_buffer)
|
||||
add_test(Internal-TestDCB test_dcb)
|
||||
|
Reference in New Issue
Block a user