diff options
author | Andrew Stitcher <astitcher@apache.org> | 2008-07-24 04:42:51 +0000 |
---|---|---|
committer | Andrew Stitcher <astitcher@apache.org> | 2008-07-24 04:42:51 +0000 |
commit | 3e0f90a2ac7d708ef693a255a9ed4feafffb2131 (patch) | |
tree | 5588d53e47269a81a3b1181be02da9929faf1321 /cpp/src/qpid/client/ConnectionImpl.cpp | |
parent | 2fc957e3d28fa3b084ef334b702bb5116f60c462 (diff) | |
download | qpid-python-3e0f90a2ac7d708ef693a255a9ed4feafffb2131.tar.gz |
Refactor to change client connector state machine to be held in ConnectionHandler
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@679268 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/client/ConnectionImpl.cpp')
-rw-r--r-- | cpp/src/qpid/client/ConnectionImpl.cpp | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp index f32e21c389..e094e13fff 100644 --- a/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/cpp/src/qpid/client/ConnectionImpl.cpp @@ -40,9 +40,7 @@ ConnectionImpl::ConnectionImpl(framing::ProtocolVersion v, const ConnectionSetti : Bounds(settings.maxFrameSize * settings.bounds), handler(settings, v), connector(new Connector(v, settings, this)), - version(v), - isClosed(true),//closed until successfully opened - isClosing(false) + version(v) { QPID_LOG(debug, "ConnectionImpl created for " << version); handler.in = boost::bind(&ConnectionImpl::incoming, this, _1); @@ -91,7 +89,7 @@ void ConnectionImpl::incoming(framing::AMQFrame& frame) bool ConnectionImpl::isOpen() const { - return !isClosed && !isClosing; + return handler.isOpen(); } @@ -101,8 +99,6 @@ void ConnectionImpl::open(const std::string& host, int port) connector->connect(host, port); connector->init(); handler.waitForOpen(); - Mutex::ScopedLock l(lock); - isClosed = false; } void ConnectionImpl::idleIn() @@ -118,19 +114,13 @@ void ConnectionImpl::idleOut() void ConnectionImpl::close() { - Mutex::ScopedLock l(lock); - if (isClosing || isClosed) return; - isClosing = true; - { - Mutex::ScopedUnlock u(lock); - handler.close(); - } + if (!handler.isOpen()) return; + handler.close(); closed(NORMAL, "Closed by client"); } template <class F> void ConnectionImpl::closeInternal(const F& f) { - isClosed = true; connector->close(); for (SessionMap::iterator i = sessions.begin(); i != sessions.end(); ++i) { boost::shared_ptr<SessionImpl> s = i->second.lock(); @@ -151,7 +141,7 @@ void ConnectionImpl::shutdown() { Mutex::ScopedLock l(lock); // FIXME aconway 2008-06-06: exception use, connection-forced is incorrect here. setException(new ConnectionException(CONNECTION_FORCED, CONN_CLOSED)); - if (isClosed) return; + if (handler.isClosed()) return; handler.fail(CONN_CLOSED); closeInternal(boost::bind(&SessionImpl::connectionBroke, _1, CONNECTION_FORCED, CONN_CLOSED)); } |