From acc0dee435e1fa22e3b1e7cdfecf6913bf88988e Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 29 Apr 2008 20:15:18 +0000 Subject: QPID-974: allow the size of the queue of outgoing frames to be restricted QPID-544: tidy up configuration (ensuring desired settings are used correctly, allowing tcp socket options to be set etc) git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@652083 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/client/ConnectionImpl.cpp | 51 +++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 22 deletions(-) (limited to 'cpp/src/qpid/client/ConnectionImpl.cpp') diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp index ce95e43f58..643d42403d 100644 --- a/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/cpp/src/qpid/client/ConnectionImpl.cpp @@ -18,13 +18,14 @@ * under the License. * */ +#include "ConnectionImpl.h" +#include "ConnectionSettings.h" +#include "SessionImpl.h" + #include "qpid/log/Statement.h" #include "qpid/framing/constants.h" #include "qpid/framing/reply_exceptions.h" -#include "ConnectionImpl.h" -#include "SessionImpl.h" - #include #include @@ -34,24 +35,32 @@ using namespace qpid::sys; using namespace qpid::framing::connection;//for connection error codes -ConnectionImpl::ConnectionImpl(boost::shared_ptr c) - : connector(c), isClosed(false), isClosing(false) +ConnectionImpl::ConnectionImpl(framing::ProtocolVersion v, const ConnectionSettings& settings) + : Bounds(settings.maxFrameSize * settings.bounds), + handler(settings, v), + connector(v, settings, this), + version(v), + isClosed(false), + isClosing(false) { + QPID_LOG(debug, "ConnectionImpl created for " << version); handler.in = boost::bind(&ConnectionImpl::incoming, this, _1); - handler.out = boost::bind(&Connector::send, connector, _1); + handler.out = boost::bind(&Connector::send, boost::ref(connector), _1); handler.onClose = boost::bind(&ConnectionImpl::closed, this, NORMAL, std::string()); handler.onError = boost::bind(&ConnectionImpl::closed, this, _1, _2); - connector->setInputHandler(&handler); - connector->setTimeoutHandler(this); - connector->setShutdownHandler(this); + connector.setInputHandler(&handler); + connector.setTimeoutHandler(this); + connector.setShutdownHandler(this); + + open(settings.host, settings.port); } ConnectionImpl::~ConnectionImpl() { // Important to close the connector first, to ensure the // connector thread does not call on us while the destructor // is running. - connector->close(); + connector.close(); } void ConnectionImpl::addSession(const boost::shared_ptr& session) @@ -79,18 +88,11 @@ void ConnectionImpl::incoming(framing::AMQFrame& frame) s->in(frame); } -void ConnectionImpl::open(const std::string& host, int port, - const std::string& uid, const std::string& pwd, - const std::string& vhost) +void ConnectionImpl::open(const std::string& host, int port) { - //TODO: better management of connection properties - handler.uid = uid; - handler.pwd = pwd; - handler.vhost = vhost; - QPID_LOG(info, "Connecting to " << host << ":" << port); - connector->connect(host, port); - connector->init(); + connector.connect(host, port); + connector.init(); handler.waitForOpen(); } @@ -102,7 +104,7 @@ void ConnectionImpl::idleIn() void ConnectionImpl::idleOut() { AMQFrame frame(in_place()); - connector->send(frame); + connector.send(frame); } void ConnectionImpl::close() @@ -121,7 +123,7 @@ void ConnectionImpl::close() // so sessions can be updated outside the lock. ConnectionImpl::SessionVector ConnectionImpl::closeInternal(const Mutex::ScopedLock&) { isClosed = true; - connector->close(); + connector.close(); SessionVector save; for (SessionMap::iterator i = sessions.begin(); i != sessions.end(); ++i) { boost::shared_ptr s = i->second.lock(); @@ -157,4 +159,9 @@ void ConnectionImpl::erase(uint16_t ch) { Mutex::ScopedLock l(lock); sessions.erase(ch); } + +const ConnectionSettings& ConnectionImpl::getNegotiatedSettings() +{ + return handler; +} -- cgit v1.2.1