diff options
author | Alan Conway <aconway@apache.org> | 2007-12-11 23:20:34 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-12-11 23:20:34 +0000 |
commit | c248015f441908139529ce40fee8d43ad3db6dba (patch) | |
tree | 490d3856c5cd8e3214cdd2b8ecf0d7068f9d93b3 /cpp | |
parent | f39ecb2d67986a450243e6fcb874d03fc5dbb318 (diff) | |
download | qpid-python-c248015f441908139529ce40fee8d43ad3db6dba.tar.gz |
Fixed client crash on error opening a connection.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@603411 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/qpid/client/ConnectionHandler.cpp | 16 | ||||
-rw-r--r-- | cpp/src/qpid/client/ConnectionImpl.cpp | 1 |
2 files changed, 12 insertions, 5 deletions
diff --git a/cpp/src/qpid/client/ConnectionHandler.cpp b/cpp/src/qpid/client/ConnectionHandler.cpp index cbdeff9cff..df84a98811 100644 --- a/cpp/src/qpid/client/ConnectionHandler.cpp +++ b/cpp/src/qpid/client/ConnectionHandler.cpp @@ -102,12 +102,18 @@ void ConnectionHandler::waitForOpen() void ConnectionHandler::close() { - if (getState() != OPEN) { - throw Exception("Connection not open"); + switch (getState()) { + case NEGOTIATING: + case OPENING: + setState(FAILED); + break; + case OPEN: + setState(CLOSING); + send(ConnectionCloseBody(version, 200, OK, 0, 0)); + waitFor(CLOSED); + break; + // Nothing to do for CLOSING, CLOSED, FAILED or NOT_STARTED } - setState(CLOSING); - send(ConnectionCloseBody(version, 200, OK, 0, 0)); - waitFor(CLOSED); } void ConnectionHandler::send(const framing::AMQBody& body) diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp index cf00b2b296..ea467429a1 100644 --- a/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/cpp/src/qpid/client/ConnectionImpl.cpp @@ -88,6 +88,7 @@ void ConnectionImpl::open(const std::string& host, int port, void ConnectionImpl::close() { + Mutex::ScopedLock l(lock); if (!isClosed) handler.close(); } |