From 496a602e2fc76224f835b379a3b301f35f2fac8e Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 26 Sep 2014 15:27:22 +0000 Subject: QPID-6123: allow for change in engine API introduced in 0.8 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1627809 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/amqp.cmake | 3 +++ qpid/cpp/src/config.h.cmake | 1 + qpid/cpp/src/qpid/broker/amqp/Connection.cpp | 30 +++++++++++++++++----- .../src/qpid/messaging/amqp/ConnectionContext.cpp | 30 +++++++++++++++++----- 4 files changed, 52 insertions(+), 12 deletions(-) (limited to 'qpid/cpp/src') diff --git a/qpid/cpp/src/amqp.cmake b/qpid/cpp/src/amqp.cmake index 85617ec59c..3be9f520e0 100644 --- a/qpid/cpp/src/amqp.cmake +++ b/qpid/cpp/src/amqp.cmake @@ -33,6 +33,9 @@ if (Proton_FOUND) if (NOT Proton_VERSION EQUAL 0.5) set (HAVE_PROTON_TRACER 1) endif (NOT Proton_VERSION EQUAL 0.5) + if (Proton_VERSION GREATER 0.7) + set (USE_PROTON_TRANSPORT_CONDITION 1) + endif (Proton_VERSION GREATER 0.7) else () message(STATUS "Qpid proton not found, amqp 1.0 support not enabled") endif () diff --git a/qpid/cpp/src/config.h.cmake b/qpid/cpp/src/config.h.cmake index 9e45a9cbb9..f8139262d5 100644 --- a/qpid/cpp/src/config.h.cmake +++ b/qpid/cpp/src/config.h.cmake @@ -57,5 +57,6 @@ #cmakedefine HAVE_LOG_AUTHPRIV #cmakedefine HAVE_LOG_FTP #cmakedefine HAVE_PROTON_TRACER +#cmakedefine USE_PROTON_TRANSPORT_CONDITION #endif /* QPID_CONFIG_H */ diff --git a/qpid/cpp/src/qpid/broker/amqp/Connection.cpp b/qpid/cpp/src/qpid/broker/amqp/Connection.cpp index 6754afc0d8..6042af3580 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Connection.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Connection.cpp @@ -59,6 +59,29 @@ void set_tracer(pn_transport_t*, void*) { } #endif + +#ifdef USE_PROTON_TRANSPORT_CONDITION +std::string get_error(pn_connection_t* connection, pn_transport_t* transport) +{ + std::stringstream text; + pn_error_t* cerror = pn_connection_error(connection); + if (cerror) text << "connection error " << pn_error_text(cerror) << " [" << cerror << "]"; + pn_condition_t* tcondition = pn_transport_condition(transport); + if (pn_condition_is_set(tcondition)) text << "transport error: " << pn_condition_get_name(tcondition) << ", " << pn_condition_get_description(tcondition); + return text.str(); +} +#else +std::string get_error(pn_connection_t* connection, pn_transport_t* transport) +{ + std::stringstream text; + pn_error_t* cerror = pn_connection_error(connection); + if (cerror) text << "connection error " << pn_error_text(cerror) << " [" << cerror << "]"; + pn_error_t* terror = pn_transport_error(transport); + if (terror) text << "transport error " << pn_error_text(terror) << " [" << terror << "]"; + return text.str(); +} +#endif + } void Connection::trace(const char* message) const @@ -384,12 +407,7 @@ void Connection::processDeliveries() std::string Connection::getError() { - std::stringstream text; - pn_error_t* cerror = pn_connection_error(connection); - if (cerror) text << "connection error " << pn_error_text(cerror) << " [" << cerror << "]"; - pn_error_t* terror = pn_transport_error(transport); - if (terror) text << "transport error " << pn_error_text(terror) << " [" << terror << "]"; - return text.str(); + return get_error(connection, transport); } void Connection::abort() diff --git a/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp b/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp index 3bee64b9d1..fedab4286f 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp @@ -72,6 +72,29 @@ void set_tracer(pn_transport_t*, void*) { } #endif + +#ifdef USE_PROTON_TRANSPORT_CONDITION +std::string get_error(pn_connection_t* connection, pn_transport_t* transport) +{ + std::stringstream text; + pn_error_t* cerror = pn_connection_error(connection); + if (cerror) text << "connection error " << pn_error_text(cerror) << " [" << cerror << "]"; + pn_condition_t* tcondition = pn_transport_condition(transport); + if (pn_condition_is_set(tcondition)) text << "transport error: " << pn_condition_get_name(tcondition) << ", " << pn_condition_get_description(tcondition); + return text.str(); +} +#else +std::string get_error(pn_connection_t* connection, pn_transport_t* transport) +{ + std::stringstream text; + pn_error_t* cerror = pn_connection_error(connection); + if (cerror) text << "connection error " << pn_error_text(cerror) << " [" << cerror << "]"; + pn_error_t* terror = pn_transport_error(transport); + if (terror) text << "transport error " << pn_error_text(terror) << " [" << terror << "]"; + return text.str(); +} +#endif + } void ConnectionContext::trace(const char* message) const @@ -805,12 +828,7 @@ qpid::framing::ProtocolVersion AMQP_1_0_PLAIN(1,0,qpid::framing::ProtocolVersion std::string ConnectionContext::getError() { - std::stringstream text; - pn_error_t* cerror = pn_connection_error(connection); - if (cerror) text << "connection error " << pn_error_text(cerror); - pn_error_t* terror = pn_transport_error(engine); - if (terror) text << "transport error " << pn_error_text(terror); - return text.str(); + return get_error(connection, engine); } framing::ProtocolVersion ConnectionContext::getVersion() const -- cgit v1.2.1