From 10e021052fdcae68b0fcc425bea2611be2a53839 Mon Sep 17 00:00:00 2001 From: Carl Cook Date: Tue, 2 Oct 2018 21:32:15 +1300 Subject: [PATCH 1/4] Tweaks to get building --- CMakeLists.txt | 8 +++++++- include/amqpcpp/libboostasio.h | 4 ++-- include/amqpcpp/linux_tcp/tcphandler.h | 12 ++++++------ src/linux_tcp/pipe.h | 3 ++- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87dbbb0..06c5866 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ set (SO_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}) # build options option(AMQP-CPP_BUILD_SHARED "Build shared library. If off, build will be static." OFF) -option(AMQP-CPP_LINUX_TCP "Build linux sockets implementation." OFF) +option(AMQP-CPP_LINUX_TCP "Build linux sockets implementation." ON) option(AMQP-CPP_BUILD_EXAMPLES "Build amqpcpp examples" OFF) # ensure c++11 on all compilers @@ -115,3 +115,9 @@ set(PRIVATE_LIBS "-llibamqpcc") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/amqpcpp.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/amqpcpp.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/amqpcpp.pc" DESTINATION lib/pkgconfig) + +target_include_directories(${PROJECT_NAME} PUBLIC + $ + $ +) +target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS}) diff --git a/include/amqpcpp/libboostasio.h b/include/amqpcpp/libboostasio.h index c1492f5..68daf20 100644 --- a/include/amqpcpp/libboostasio.h +++ b/include/amqpcpp/libboostasio.h @@ -176,7 +176,7 @@ protected: * @note The handler will get called if a read is cancelled. */ void read_handler(const boost::system::error_code &ec, - const std::size_t bytes_transferred, + const std::size_t, const std::weak_ptr awpWatcher, TcpConnection *const connection, const int fd) @@ -210,7 +210,7 @@ protected: * @note The handler will get called if a write is cancelled. */ void write_handler(const boost::system::error_code ec, - const std::size_t bytes_transferred, + const std::size_t, const std::weak_ptr awpWatcher, TcpConnection *const connection, const int fd) diff --git a/include/amqpcpp/linux_tcp/tcphandler.h b/include/amqpcpp/linux_tcp/tcphandler.h index 9b0c87d..08ffc0f 100644 --- a/include/amqpcpp/linux_tcp/tcphandler.h +++ b/include/amqpcpp/linux_tcp/tcphandler.h @@ -56,7 +56,7 @@ public: * @param ssl Pointer to the SSL structure that can be inspected * @return bool True to proceed / accept the connection, false to break up */ - virtual bool onSecured(TcpConnection *connection, const SSL *ssl) + virtual bool onSecured(TcpConnection *, const SSL *) { // default implementation: do not inspect anything, just allow the connection return true; @@ -73,7 +73,7 @@ public: * * @see ConnectionHandler::onNegotiate */ - virtual uint16_t onNegotiate(TcpConnection *connection, uint16_t interval) + virtual uint16_t onNegotiate(TcpConnection *, uint16_t interval) { // default implementation, suggested heartbeat is ok return interval; @@ -85,7 +85,7 @@ public: * secure TLS connection, and the AMQP login handshake has been completed. * @param connection The TCP connection */ - virtual void onConnected(TcpConnection *connection) {} + virtual void onConnected(TcpConnection *) {} /** * Method that is called when the server sends a heartbeat to the client @@ -93,20 +93,20 @@ public: * * @see ConnectionHandler::onHeartbeat */ - virtual void onHeartbeat(TcpConnection *connection) {} + virtual void onHeartbeat(TcpConnection *) {} /** * Method that is called when the TCP connection ends up in an error state * @param connection The TCP connection * @param message Error message */ - virtual void onError(TcpConnection *connection, const char *message) {} + virtual void onError(TcpConnection *, const char *) {} /** * Method that is called when the TCP connection is closed * @param connection The TCP connection */ - virtual void onClosed(TcpConnection *connection) {} + virtual void onClosed(TcpConnection *) {} /** * Monitor a filedescriptor for readability or writability diff --git a/src/linux_tcp/pipe.h b/src/linux_tcp/pipe.h index d374d7b..c7b4464 100644 --- a/src/linux_tcp/pipe.h +++ b/src/linux_tcp/pipe.h @@ -82,7 +82,8 @@ public: char byte = 0; // send one byte over the pipe - this will wake up the other thread - write(_fds[1], &byte, 1); + if (write(_fds[1], &byte, 1) == -1) + throw std::runtime_error(strerror(errno)); } }; From 36cfbd4d37c16d6328528dffdc691a6b002d89dc Mon Sep 17 00:00:00 2001 From: Maciej Gajewski Date: Tue, 2 Oct 2018 16:25:00 +0200 Subject: [PATCH 2/4] cmake include path fixed to be a system include --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 06c5866..a3f858d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ set (CMAKE_CXX_STANDARD 11) # ------------------------------------------------------------------------------------------------------ # set include/ as include directory -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) +include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/include) # macro that adds a list of provided source files to a list called SRCS. # if variable SRCS does not yet exist, it is created. @@ -116,7 +116,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/amqpcpp.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/amqpcpp.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/amqpcpp.pc" DESTINATION lib/pkgconfig) -target_include_directories(${PROJECT_NAME} PUBLIC +target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC $ $ ) From d3f4d28ecdd143c1f7b55c92e59aa259ce477f9b Mon Sep 17 00:00:00 2001 From: Carl Cook Date: Wed, 3 Oct 2018 10:29:19 +1300 Subject: [PATCH 3/4] Reverted override of option (and other minor changes) --- CMakeLists.txt | 2 +- include/amqpcpp/libboostasio.h | 4 ++-- include/amqpcpp/linux_tcp/tcphandler.h | 12 ++++++------ src/linux_tcp/pipe.h | 3 +-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3f858d..7c84747 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ set (SO_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}) # build options option(AMQP-CPP_BUILD_SHARED "Build shared library. If off, build will be static." OFF) -option(AMQP-CPP_LINUX_TCP "Build linux sockets implementation." ON) +option(AMQP-CPP_LINUX_TCP "Build linux sockets implementation." OFF) option(AMQP-CPP_BUILD_EXAMPLES "Build amqpcpp examples" OFF) # ensure c++11 on all compilers diff --git a/include/amqpcpp/libboostasio.h b/include/amqpcpp/libboostasio.h index 68daf20..c1492f5 100644 --- a/include/amqpcpp/libboostasio.h +++ b/include/amqpcpp/libboostasio.h @@ -176,7 +176,7 @@ protected: * @note The handler will get called if a read is cancelled. */ void read_handler(const boost::system::error_code &ec, - const std::size_t, + const std::size_t bytes_transferred, const std::weak_ptr awpWatcher, TcpConnection *const connection, const int fd) @@ -210,7 +210,7 @@ protected: * @note The handler will get called if a write is cancelled. */ void write_handler(const boost::system::error_code ec, - const std::size_t, + const std::size_t bytes_transferred, const std::weak_ptr awpWatcher, TcpConnection *const connection, const int fd) diff --git a/include/amqpcpp/linux_tcp/tcphandler.h b/include/amqpcpp/linux_tcp/tcphandler.h index 08ffc0f..9b0c87d 100644 --- a/include/amqpcpp/linux_tcp/tcphandler.h +++ b/include/amqpcpp/linux_tcp/tcphandler.h @@ -56,7 +56,7 @@ public: * @param ssl Pointer to the SSL structure that can be inspected * @return bool True to proceed / accept the connection, false to break up */ - virtual bool onSecured(TcpConnection *, const SSL *) + virtual bool onSecured(TcpConnection *connection, const SSL *ssl) { // default implementation: do not inspect anything, just allow the connection return true; @@ -73,7 +73,7 @@ public: * * @see ConnectionHandler::onNegotiate */ - virtual uint16_t onNegotiate(TcpConnection *, uint16_t interval) + virtual uint16_t onNegotiate(TcpConnection *connection, uint16_t interval) { // default implementation, suggested heartbeat is ok return interval; @@ -85,7 +85,7 @@ public: * secure TLS connection, and the AMQP login handshake has been completed. * @param connection The TCP connection */ - virtual void onConnected(TcpConnection *) {} + virtual void onConnected(TcpConnection *connection) {} /** * Method that is called when the server sends a heartbeat to the client @@ -93,20 +93,20 @@ public: * * @see ConnectionHandler::onHeartbeat */ - virtual void onHeartbeat(TcpConnection *) {} + virtual void onHeartbeat(TcpConnection *connection) {} /** * Method that is called when the TCP connection ends up in an error state * @param connection The TCP connection * @param message Error message */ - virtual void onError(TcpConnection *, const char *) {} + virtual void onError(TcpConnection *connection, const char *message) {} /** * Method that is called when the TCP connection is closed * @param connection The TCP connection */ - virtual void onClosed(TcpConnection *) {} + virtual void onClosed(TcpConnection *connection) {} /** * Monitor a filedescriptor for readability or writability diff --git a/src/linux_tcp/pipe.h b/src/linux_tcp/pipe.h index c7b4464..d374d7b 100644 --- a/src/linux_tcp/pipe.h +++ b/src/linux_tcp/pipe.h @@ -82,8 +82,7 @@ public: char byte = 0; // send one byte over the pipe - this will wake up the other thread - if (write(_fds[1], &byte, 1) == -1) - throw std::runtime_error(strerror(errno)); + write(_fds[1], &byte, 1); } }; From 4b215f6ea3a89aa45f7e9e5050ab35e0a3d81dc7 Mon Sep 17 00:00:00 2001 From: Carl Cook Date: Wed, 3 Oct 2018 10:41:34 +1300 Subject: [PATCH 4/4] Only link dl if using tcp lib --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c84747..437d803 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,8 +116,13 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/amqpcpp.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/amqpcpp.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/amqpcpp.pc" DESTINATION lib/pkgconfig) +# submodule support +# ------------------------------------------------------------------------------------------------------ target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC $ $ ) -target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS}) + +if(AMQP-CPP_LINUX_TCP) + target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS}) +endif()