From ab6418c939deac3d25705ee40c0ada65e7b31267 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 30 Jan 2015 18:03:20 +0200 Subject: [PATCH] Fixes to RabbitMQ filter and consumer. --- CMakeLists.txt | 4 ---- rabbitmq_consumer/CMakeLists.txt | 6 ++++-- rabbitmq_consumer/buildconfig.inc | 8 -------- rabbitmq_consumer/consumer.c | 7 +++++++ server/modules/filter/CMakeLists.txt | 4 +++- server/modules/filter/mqfilter.c | 2 +- 6 files changed, 15 insertions(+), 16 deletions(-) delete mode 100644 rabbitmq_consumer/buildconfig.inc diff --git a/CMakeLists.txt b/CMakeLists.txt index 8606335a6..281e30eca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,10 +100,6 @@ add_subdirectory(server) if(NOT WITHOUT_MAXADMIN) add_subdirectory(client) endif() -if(BUILD_RABBITMQ) - find_package(RabbitMQ) - add_subdirectory(rabbitmq_consumer) -endif() file(GLOB DOCS Documentation/*.pdf) message(STATUS "Installing MaxScale to: ${CMAKE_INSTALL_PREFIX}/") diff --git a/rabbitmq_consumer/CMakeLists.txt b/rabbitmq_consumer/CMakeLists.txt index 170c19e01..655620a3c 100644 --- a/rabbitmq_consumer/CMakeLists.txt +++ b/rabbitmq_consumer/CMakeLists.txt @@ -3,10 +3,11 @@ include(../macros.cmake) enable_testing() set_variables() set(CMAKE_INSTALL_PREFIX "/usr/local/skysql/rabbitmq-consumer" CACHE PATH "Prefix prepended to install directories.") -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../cmake") project("RabbitMQ Consumer") +configure_file(${CMAKE_SOURCE_DIR}/consumer.c ${CMAKE_BINARY_DIR}/consumer.c) find_package(RabbitMQ) find_package(MySQLClient) @@ -14,9 +15,10 @@ find_package(MySQLClient) set(CMAKE_C_FLAGS "-Wall -fPIC") set(CMAKE_CXX_FLAGS "-Wall -fPIC") include_directories(${MYSQLCLIENT_HEADERS}) +include_directories(${RABBITMQ_HEADERS}) include_directories(inih) add_subdirectory(inih) -add_executable (consumer consumer.c) +add_executable (consumer ${CMAKE_BINARY_DIR}/consumer.c) if(MYSQLCLIENT_FOUND) target_link_libraries(consumer ${MYSQLCLIENT_LIBRARIES} rabbitmq inih ssl crypt crypto dl z m pthread) diff --git a/rabbitmq_consumer/buildconfig.inc b/rabbitmq_consumer/buildconfig.inc deleted file mode 100644 index ab0f2f887..000000000 --- a/rabbitmq_consumer/buildconfig.inc +++ /dev/null @@ -1,8 +0,0 @@ -#Use the '-I' prefix for include and '-L' for library directories -#You can use multiple library and include directories - -#Path to the rabbitmq-c and mysqlclient libraries -LIBRARY_DIRS :=-L/usr/lib64 - -#path to headers -INCLUDE_DIRS :=-I/usr/include -I/usr/include/mysql \ No newline at end of file diff --git a/rabbitmq_consumer/consumer.c b/rabbitmq_consumer/consumer.c index 7e9ba5ea3..6712fbfe5 100644 --- a/rabbitmq_consumer/consumer.c +++ b/rabbitmq_consumer/consumer.c @@ -337,6 +337,7 @@ int main(int argc, char** argv) MYSQL db_inst; char ch, *cnfname = NULL, *cnfpath = NULL; static const char* fname = "consumer.cnf"; + const char* default_path = "@CMAKE_INSTALL_PREFIX@/etc"; if((c_inst = calloc(1,sizeof(CONSUMER))) == NULL){ fprintf(stderr, "Fatal Error: Cannot allocate enough memory.\n"); @@ -359,6 +360,12 @@ int main(int argc, char** argv) } } +if(cnfpath == NULL) +{ + cnfpath = strdup(default_path); + cnfnlen = strlen(default_path); +} + cnfname = calloc(cnfnlen + strlen(fname) + 1,sizeof(char)); if(cnfpath){ diff --git a/server/modules/filter/CMakeLists.txt b/server/modules/filter/CMakeLists.txt index 231c31236..87520abc7 100644 --- a/server/modules/filter/CMakeLists.txt +++ b/server/modules/filter/CMakeLists.txt @@ -1,6 +1,8 @@ if(BUILD_RABBITMQ) + find_package(RabbitMQ) + include_directories(${RABBITMQ_HEADERS}) add_library(mqfilter SHARED mqfilter.c) - target_link_libraries(mqfilter query_classifier log_manager utils rabbitmq) + target_link_libraries(mqfilter query_classifier log_manager utils ${RABBITMQ_LIBRARIES}) install(TARGETS mqfilter DESTINATION modules) endif() diff --git a/server/modules/filter/mqfilter.c b/server/modules/filter/mqfilter.c index f88297e8f..86059c7bc 100644 --- a/server/modules/filter/mqfilter.c +++ b/server/modules/filter/mqfilter.c @@ -36,7 +36,7 @@ * * logging_trigger Set the logging level * logging_strict Sets whether to trigger when any of the parameters match or only if all parameters match - * logging_log_all Log only SELECT, UPDATE, DELETE and INSERT or all posddible queries + * logging_log_all Log only SELECT, UPDATE, DELETE and INSERT or all possible queries * hostname The server hostname where the messages are sent * port Port to send the messages to * username Server login username