diff options
author | Gordon Sim <gsim@apache.org> | 2008-04-22 10:33:12 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2008-04-22 10:33:12 +0000 |
commit | 2b8e82875776feb8393c7791975acc9cf9fdb5e1 (patch) | |
tree | 1dda91e21db631a53fc796ffe6a12190895ba0db /cpp/src/qpid/client/ConnectionHandler.cpp | |
parent | a00e277846fb1ad432988e582506c7a4223e7d67 (diff) | |
download | qpid-python-2b8e82875776feb8393c7791975acc9cf9fdb5e1.tar.gz |
QPID-648: (based on patch from mfarrellee@redhat.com)
* apply authentication to final 0-10 codepath
* consolidate conditional compilation of sasl-related code
* improved handling of connection close during connection establishment in client
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@650439 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/client/ConnectionHandler.cpp')
-rw-r--r-- | cpp/src/qpid/client/ConnectionHandler.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/cpp/src/qpid/client/ConnectionHandler.cpp b/cpp/src/qpid/client/ConnectionHandler.cpp index 13de271e3b..83cc357ded 100644 --- a/cpp/src/qpid/client/ConnectionHandler.cpp +++ b/cpp/src/qpid/client/ConnectionHandler.cpp @@ -42,7 +42,7 @@ const std::string INVALID_STATE_CLOSE_OK("close-ok received in invalid state"); } ConnectionHandler::ConnectionHandler() - : StateManager(NOT_STARTED), outHandler(*this), proxy(outHandler) + : StateManager(NOT_STARTED), outHandler(*this), proxy(outHandler), errorCode(200) { mechanism = PLAIN; @@ -54,6 +54,7 @@ ConnectionHandler::ConnectionHandler() version = framing::highestProtocolVersion; ESTABLISHED.insert(FAILED); + ESTABLISHED.insert(CLOSED); ESTABLISHED.insert(OPEN); } @@ -98,8 +99,8 @@ void ConnectionHandler::outgoing(AMQFrame& frame) void ConnectionHandler::waitForOpen() { waitFor(ESTABLISHED); - if (getState() == FAILED) { - throw Exception("Failed to establish connection."); + if (getState() == FAILED || getState() == CLOSED) { + throw ConnectionException(errorCode, errorText); } } @@ -108,7 +109,7 @@ void ConnectionHandler::close() switch (getState()) { case NEGOTIATING: case OPENING: - setState(FAILED); + fail("Connection closed before it was established"); break; case OPEN: setState(CLOSING); @@ -128,6 +129,8 @@ void ConnectionHandler::checkState(STATES s, const std::string& msg) void ConnectionHandler::fail(const std::string& message) { + errorCode = 502; + errorText = message; QPID_LOG(warning, message); setState(FAILED); } @@ -172,6 +175,8 @@ void ConnectionHandler::close(uint16_t replyCode, const std::string& replyText) { proxy.closeOk(); setState(CLOSED); + errorCode = replyCode; + errorText = replyText; QPID_LOG(warning, "Broker closed connection: " << replyCode << ", " << replyText); if (onError) { onError(replyCode, replyText); |