diff options
| author | Gordon Sim <gsim@apache.org> | 2008-11-06 22:08:14 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2008-11-06 22:08:14 +0000 |
| commit | 2de0473cf8c64e06396c5f5e6a0cf8b5e982514e (patch) | |
| tree | e16cb5c31d3c6399e5e3eeb0f50b793d55b1ad13 /cpp/src/qpid/broker | |
| parent | e1132d45340a4d1c91648cac856803428d2a60f4 (diff) | |
| download | qpid-python-2de0473cf8c64e06396c5f5e6a0cf8b5e982514e.tar.gz | |
Restrict connection close codes to the set defined in the spec
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@711989 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker')
| -rw-r--r-- | cpp/src/qpid/broker/Connection.cpp | 15 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/Connection.h | 5 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/ConnectionHandler.cpp | 2 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/ConnectionHandler.h | 3 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/Link.cpp | 6 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/SessionAdapter.cpp | 6 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/SessionHandler.cpp | 8 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/SessionHandler.h | 4 |
8 files changed, 23 insertions, 26 deletions
diff --git a/cpp/src/qpid/broker/Connection.cpp b/cpp/src/qpid/broker/Connection.cpp index 28ab6cbf1b..4dbfb153f2 100644 --- a/cpp/src/qpid/broker/Connection.cpp +++ b/cpp/src/qpid/broker/Connection.cpp @@ -164,11 +164,10 @@ void Connection::setFederationLink(bool b) mgmtObject->set_federationLink(b); } -void Connection::close( - ReplyCode code, const string& text, ClassId classId, MethodId methodId) +void Connection::close(connection::CloseCode code, const string& text) { - QPID_LOG_IF(error, code != 200, "Connection " << mgmtId << " closed by error: " << text << "(" << code << ")"); - adapter.close(code, text, classId, methodId); + QPID_LOG_IF(error, code != connection::CLOSE_CODE_NORMAL, "Connection " << mgmtId << " closed by error: " << text << "(" << code << ")"); + adapter.close(code, text); //make sure we delete dangling pointers from outputTasks before deleting sessions outputTasks.removeAll(); channels.clear(); @@ -177,7 +176,7 @@ void Connection::close( // Send a close to the client but keep the channels. Used by cluster. void Connection::sendClose() { - adapter.close(200, "OK", 0, 0); + adapter.close(connection::CLOSE_CODE_NORMAL, "OK"); getOutput().close(); } @@ -212,14 +211,14 @@ bool Connection::doOutput() { ioCallback = 0; if (mgmtClosing) - close(execution::ERROR_CODE_UNAUTHORIZED_ACCESS, "Closed by Management Request", 0, 0); + close(connection::CLOSE_CODE_CONNECTION_FORCED, "Closed by Management Request"); else //then do other output as needed: return outputTasks.doOutput(); }catch(ConnectionException& e){ - close(e.code, e.getMessage(), 0, 0); + close(e.code, e.getMessage()); }catch(std::exception& e){ - close(execution::ERROR_CODE_INTERNAL_ERROR, e.what(), 0, 0); + close(connection::CLOSE_CODE_CONNECTION_FORCED, e.what()); } return false; } diff --git a/cpp/src/qpid/broker/Connection.h b/cpp/src/qpid/broker/Connection.h index 87cda02971..8ab58c1067 100644 --- a/cpp/src/qpid/broker/Connection.h +++ b/cpp/src/qpid/broker/Connection.h @@ -69,10 +69,7 @@ class Connection : public sys::ConnectionInputHandler, SessionHandler& getChannel(framing::ChannelId channel); /** Close the connection */ - void close(framing::ReplyCode code = 403, - const string& text = string(), - framing::ClassId classId = 0, - framing::MethodId methodId = 0); + void close(framing::connection::CloseCode code, const string& text); // ConnectionInputHandler methods void received(framing::AMQFrame& frame); diff --git a/cpp/src/qpid/broker/ConnectionHandler.cpp b/cpp/src/qpid/broker/ConnectionHandler.cpp index c55db2c339..8639b7949e 100644 --- a/cpp/src/qpid/broker/ConnectionHandler.cpp +++ b/cpp/src/qpid/broker/ConnectionHandler.cpp @@ -43,7 +43,7 @@ const std::string QPID_FED_LINK = "qpid.fed_link"; const std::string QPID_FED_TAG = "qpid.federation_tag"; } -void ConnectionHandler::close(ReplyCode code, const string& text, ClassId, MethodId) +void ConnectionHandler::close(connection::CloseCode code, const string& text) { handler->client.close(code, text); } diff --git a/cpp/src/qpid/broker/ConnectionHandler.h b/cpp/src/qpid/broker/ConnectionHandler.h index 9d8a091f21..d3d5965dfc 100644 --- a/cpp/src/qpid/broker/ConnectionHandler.h +++ b/cpp/src/qpid/broker/ConnectionHandler.h @@ -29,6 +29,7 @@ #include "qpid/framing/AMQP_ClientProxy.h" #include "qpid/framing/AMQP_ServerOperations.h" #include "qpid/framing/AMQP_ServerProxy.h" +#include "qpid/framing/enum.h" #include "qpid/framing/FrameHandler.h" #include "qpid/framing/ProtocolInitiation.h" #include "qpid/framing/ProtocolVersion.h" @@ -84,7 +85,7 @@ class ConnectionHandler : public framing::FrameHandler std::auto_ptr<Handler> handler; public: ConnectionHandler(Connection& connection, bool isClient); - void close(framing::ReplyCode code, const std::string& text, framing::ClassId classId, framing::MethodId methodId); + void close(framing::connection::CloseCode code, const std::string& text); void handle(framing::AMQFrame& frame); }; diff --git a/cpp/src/qpid/broker/Link.cpp b/cpp/src/qpid/broker/Link.cpp index 4f9b8bc104..d2886050dd 100644 --- a/cpp/src/qpid/broker/Link.cpp +++ b/cpp/src/qpid/broker/Link.cpp @@ -26,6 +26,7 @@ #include "qpid/agent/ManagementAgent.h" #include "boost/bind.hpp" #include "qpid/log/Statement.h" +#include "qpid/framing/enum.h" #include "qpid/framing/reply_exceptions.h" #include "AclModule.h" @@ -33,6 +34,7 @@ using namespace qpid::broker; using qpid::framing::Buffer; using qpid::framing::FieldTable; using qpid::framing::NotAllowedException; +using qpid::framing::connection::CLOSE_CODE_CONNECTION_FORCED; using qpid::management::ManagementAgent; using qpid::management::ManagementObject; using qpid::management::Manageable; @@ -78,7 +80,7 @@ Link::Link(LinkRegistry* _links, Link::~Link () { if (state == STATE_OPERATIONAL && connection != 0) - connection->close(); + connection->close(CLOSE_CODE_CONNECTION_FORCED, "closed by management"); if (mgmtObject != 0) mgmtObject->resourceDestroy (); @@ -169,7 +171,7 @@ void Link::destroy () QPID_LOG (info, "Inter-broker link to " << host << ":" << port << " removed by management"); if (connection) - connection->close(403, "closed by management"); + connection->close(CLOSE_CODE_CONNECTION_FORCED, "closed by management"); setStateLH(STATE_CLOSED); diff --git a/cpp/src/qpid/broker/SessionAdapter.cpp b/cpp/src/qpid/broker/SessionAdapter.cpp index d66157d8d4..15a47de45d 100644 --- a/cpp/src/qpid/broker/SessionAdapter.cpp +++ b/cpp/src/qpid/broker/SessionAdapter.cpp @@ -22,7 +22,6 @@ #include "qpid/framing/reply_exceptions.h" #include "qpid/framing/enum.h" #include "qpid/log/Statement.h" -#include "qpid/amqp_0_10/exceptions.h" #include "qpid/framing/SequenceSet.h" #include "qpid/agent/ManagementAgent.h" #include "qmf/org/apache/qpid/broker/EventExchangeDeclare.h" @@ -405,7 +404,6 @@ void SessionAdapter::QueueHandlerImpl::delete_(const string& queue, bool ifUnuse throw NotAllowedException("ACL denied queue delete request"); } - ChannelException error(0, ""); Queue::shared_ptr q = getQueue(queue); if(ifEmpty && q->getMessageCount() > 0){ throw PreconditionFailedException("Queue not empty."); @@ -731,11 +729,11 @@ void SessionAdapter::DtxHandlerImpl::setTimeout(const Xid& xid, Queue::shared_ptr SessionAdapter::HandlerHelper::getQueue(const string& name) const { Queue::shared_ptr queue; if (name.empty()) { - throw amqp_0_10::IllegalArgumentException(QPID_MSG("No queue name specified.")); + throw framing::IllegalArgumentException(QPID_MSG("No queue name specified.")); } else { queue = session.getBroker().getQueues().find(name); if (!queue) - throw amqp_0_10::NotFoundException(QPID_MSG("Queue not found: "<<name)); + throw framing::NotFoundException(QPID_MSG("Queue not found: "<<name)); } return queue; } diff --git a/cpp/src/qpid/broker/SessionHandler.cpp b/cpp/src/qpid/broker/SessionHandler.cpp index 0f67c1e0c5..163102d008 100644 --- a/cpp/src/qpid/broker/SessionHandler.cpp +++ b/cpp/src/qpid/broker/SessionHandler.cpp @@ -44,12 +44,12 @@ ClassId classId(AMQMethodBody* m) { return m ? m->amqpMethodId() : 0; } MethodId methodId(AMQMethodBody* m) { return m ? m->amqpClassId() : 0; } } // namespace -void SessionHandler::channelException(uint16_t, const std::string&) { - handleDetach(); +void SessionHandler::channelException(framing::session::DetachCode, const std::string&) { + handleDetach(); } -void SessionHandler::connectionException(uint16_t code, const std::string& msg) { - connection.close(code, msg, 0, 0); +void SessionHandler::connectionException(framing::connection::CloseCode code, const std::string& msg) { + connection.close(code, msg); } ConnectionState& SessionHandler::getConnection() { return connection; } diff --git a/cpp/src/qpid/broker/SessionHandler.h b/cpp/src/qpid/broker/SessionHandler.h index a8f741bc1b..7449db1560 100644 --- a/cpp/src/qpid/broker/SessionHandler.h +++ b/cpp/src/qpid/broker/SessionHandler.h @@ -63,8 +63,8 @@ class SessionHandler : public amqp_0_10::SessionHandler { virtual void setState(const std::string& sessionName, bool force); virtual qpid::SessionState* getState(); virtual framing::FrameHandler* getInHandler(); - virtual void channelException(uint16_t code, const std::string& msg); - virtual void connectionException(uint16_t code, const std::string& msg); + virtual void channelException(framing::session::DetachCode code, const std::string& msg); + virtual void connectionException(framing::connection::CloseCode code, const std::string& msg); virtual void detaching(); virtual void readyToSend(); |
