diff options
| author | Alan Conway <aconway@apache.org> | 2010-06-08 15:31:31 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2010-06-08 15:31:31 +0000 |
| commit | 9c8302099de20be264d1bf357b6bceb963ada021 (patch) | |
| tree | abd4d1ede4af4dc9dcc6427b2b40c51441b51f5f /cpp/src/qpid/broker | |
| parent | c116d46cc03b19304ce51e047ab31519098380fa (diff) | |
| download | qpid-python-9c8302099de20be264d1bf357b6bceb963ada021.tar.gz | |
Cluster handle connection-negotiation phase in local broker.
The connection negotiation phase up to the "open" or "open-ok" frame
establishes whether/what encryption to use for the rest of the
connection.
With this patch a cluster broker completes the initial negotiation
with its local clients and only then begins multicasting to other
brokers. The local broker decrypts if necessary and multicasts in the
clear.
This replaces a problematic locking scheme that was formerly in place
which caused deadlocks.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@952692 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker')
| -rw-r--r-- | cpp/src/qpid/broker/Connection.cpp | 3 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/Connection.h | 8 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/ConnectionHandler.cpp | 13 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/ConnectionHandler.h | 12 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/SaslAuthenticator.h | 10 |
5 files changed, 9 insertions, 37 deletions
diff --git a/cpp/src/qpid/broker/Connection.cpp b/cpp/src/qpid/broker/Connection.cpp index 51615e5b5f..ac574fc1a3 100644 --- a/cpp/src/qpid/broker/Connection.cpp +++ b/cpp/src/qpid/broker/Connection.cpp @@ -386,7 +386,6 @@ void Connection::restartTimeout() timeoutTimer->touch(); } - - +bool Connection::isOpen() { return adapter.isOpen(); } }} diff --git a/cpp/src/qpid/broker/Connection.h b/cpp/src/qpid/broker/Connection.h index 0639bcbb42..ad9f786179 100644 --- a/cpp/src/qpid/broker/Connection.h +++ b/cpp/src/qpid/broker/Connection.h @@ -63,9 +63,6 @@ class LinkRegistry; class SecureConnection; struct ConnectionTimeoutTask; -typedef boost::function<void ( std::string& )> userIdCallback; - - class Connection : public sys::ConnectionInputHandler, public ConnectionState, public RefCounted @@ -146,9 +143,8 @@ class Connection : public sys::ConnectionInputHandler, return securitySettings; } - void setUserIdCallback ( UserIdCallback fn ) { - adapter.setUserIdCallback ( fn ); - } + /** @return true if the initial connection negotiation is complete. */ + bool isOpen(); private: typedef boost::ptr_map<framing::ChannelId, SessionHandler> ChannelMap; diff --git a/cpp/src/qpid/broker/ConnectionHandler.cpp b/cpp/src/qpid/broker/ConnectionHandler.cpp index 225735deb6..c349bc7ac7 100644 --- a/cpp/src/qpid/broker/ConnectionHandler.cpp +++ b/cpp/src/qpid/broker/ConnectionHandler.cpp @@ -87,7 +87,8 @@ ConnectionHandler::ConnectionHandler(Connection& connection, bool isClient, bool ConnectionHandler::Handler::Handler(Connection& c, bool isClient, bool isShadow) : proxy(c.getOutput()), - connection(c), serverMode(!isClient), acl(0), secured(0), userIdCallback(0) + connection(c), serverMode(!isClient), acl(0), secured(0), + isOpen(false) { if (serverMode) { @@ -195,14 +196,7 @@ void ConnectionHandler::Handler::open(const string& /*virtualHost*/, if (sl.get()) secured->activateSecurityLayer(sl); } - if ( userIdCallback ) { - string s; - // Not checking the return value of getUsername, if there is - // no username then we want to call the userIdCallback anyway - // with an empty string. - authenticator->getUsername(s); - userIdCallback(s); - } + isOpen = true; proxy.openOk(array); } @@ -272,6 +266,7 @@ void ConnectionHandler::Handler::openOk(const framing::Array& knownHosts) Url url((*i)->get<std::string>()); connection.getKnownHosts().push_back(url); } + isOpen = true; } void ConnectionHandler::Handler::redirect(const string& /*host*/, const framing::Array& /*knownHosts*/) diff --git a/cpp/src/qpid/broker/ConnectionHandler.h b/cpp/src/qpid/broker/ConnectionHandler.h index ecc8868e87..6d55cab647 100644 --- a/cpp/src/qpid/broker/ConnectionHandler.h +++ b/cpp/src/qpid/broker/ConnectionHandler.h @@ -40,9 +40,6 @@ namespace broker { class Connection; class SecureConnection; -typedef boost::function<void ( std::string& )> UserIdCallback; - - class ConnectionHandler : public framing::FrameHandler { struct Handler : public framing::AMQP_AllOperations::ConnectionHandler @@ -53,6 +50,7 @@ class ConnectionHandler : public framing::FrameHandler std::auto_ptr<SaslAuthenticator> authenticator; AclModule* acl; SecureConnection* secured; + bool isOpen; Handler(Connection& connection, bool isClient, bool isShadow=false); ~Handler(); @@ -67,10 +65,6 @@ class ConnectionHandler : public framing::FrameHandler void close(uint16_t replyCode, const std::string& replyText); void closeOk(); - UserIdCallback userIdCallback; - void setUserIdCallback ( UserIdCallback fn ) { userIdCallback = fn; }; - - void start(const qpid::framing::FieldTable& serverProperties, const framing::Array& mechanisms, const framing::Array& locales); @@ -95,9 +89,7 @@ class ConnectionHandler : public framing::FrameHandler void heartbeat(); void handle(framing::AMQFrame& frame); void setSecureConnection(SecureConnection* secured); - void setUserIdCallback ( UserIdCallback fn ) { - handler->setUserIdCallback ( fn ); - } + bool isOpen() { return handler->isOpen; } }; diff --git a/cpp/src/qpid/broker/SaslAuthenticator.h b/cpp/src/qpid/broker/SaslAuthenticator.h index b4b946f7ce..cfbe1a0cd1 100644 --- a/cpp/src/qpid/broker/SaslAuthenticator.h +++ b/cpp/src/qpid/broker/SaslAuthenticator.h @@ -36,12 +36,6 @@ namespace broker { class Connection; -// Calls your fn with the user ID string, just -// after the security negotiation is complete. -// Add your callback to the list with addUserIdCallback(). -typedef boost::function<void ( std::string& )> UserIdCallback; - - class SaslAuthenticator { public: @@ -54,7 +48,6 @@ public: virtual void getError(std::string&) {} virtual std::auto_ptr<qpid::sys::SecurityLayer> getSecurityLayer(uint16_t maxFrameSize) = 0; - virtual void setUserIdCallback ( UserIdCallback ) { } static bool available(void); // Initialize the SASL mechanism; throw if it fails. @@ -64,9 +57,6 @@ public: static std::auto_ptr<SaslAuthenticator> createAuthenticator(Connection& connection, bool isShadow); virtual void callUserIdCallbacks() { } - -private: - UserIdCallback userIdCallback; }; }} |
