diff options
| author | Andrew Stitcher <astitcher@apache.org> | 2010-09-08 16:48:45 +0000 |
|---|---|---|
| committer | Andrew Stitcher <astitcher@apache.org> | 2010-09-08 16:48:45 +0000 |
| commit | facb48d023ec46cf28fdf6c7dcb01d37e90ef83d (patch) | |
| tree | 411c2a61ffb465255db5584322cd2e145f12cfe0 | |
| parent | 1ba34c86302c704cbf0ec9aa76e9199d9fb14f5f (diff) | |
| download | qpid-python-facb48d023ec46cf28fdf6c7dcb01d37e90ef83d.tar.gz | |
Make sure that we fail connection correctly if connect fails.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@995128 13f79535-47bb-0310-9956-ffa450edef68
| -rw-r--r-- | qpid/cpp/src/qpid/client/RdmaConnector.cpp | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/qpid/cpp/src/qpid/client/RdmaConnector.cpp b/qpid/cpp/src/qpid/client/RdmaConnector.cpp index 56238b2ac7..8bcb34f352 100644 --- a/qpid/cpp/src/qpid/client/RdmaConnector.cpp +++ b/qpid/cpp/src/qpid/client/RdmaConnector.cpp @@ -28,6 +28,7 @@ #include "qpid/framing/AMQFrame.h" #include "qpid/framing/InitiationHandler.h" #include "qpid/sys/rdma/RdmaIO.h" +#include "qpid/sys/rdma/rdma_exception.h" #include "qpid/sys/Dispatcher.h" #include "qpid/sys/Poller.h" #include "qpid/sys/SecurityLayer.h" @@ -189,20 +190,34 @@ void RdmaConnector::connect(const std::string& host, int port){ // The following only gets run when connected void RdmaConnector::connected(Poller::shared_ptr poller, Rdma::Connection::intrusive_ptr ci, const Rdma::ConnectionParams& cp) { - Rdma::QueuePair::intrusive_ptr q = ci->getQueuePair(); + try { + Rdma::QueuePair::intrusive_ptr q = ci->getQueuePair(); - aio = new Rdma::AsynchIO(ci->getQueuePair(), - cp.maxRecvBufferSize, cp.initialXmitCredit , Rdma::DEFAULT_WR_ENTRIES, - boost::bind(&RdmaConnector::readbuff, this, _1, _2), - boost::bind(&RdmaConnector::writebuff, this, _1), - 0, // write buffers full - boost::bind(&RdmaConnector::dataError, this, _1)); + aio = new Rdma::AsynchIO(ci->getQueuePair(), + cp.maxRecvBufferSize, cp.initialXmitCredit , Rdma::DEFAULT_WR_ENTRIES, + boost::bind(&RdmaConnector::readbuff, this, _1, _2), + boost::bind(&RdmaConnector::writebuff, this, _1), + 0, // write buffers full + boost::bind(&RdmaConnector::dataError, this, _1)); - identifier = str(format("[%1% %2%]") % ci->getLocalName() % ci->getPeerName()); - ProtocolInitiation init(version); - writeDataBlock(init); + identifier = str(format("[%1% %2%]") % ci->getLocalName() % ci->getPeerName()); + ProtocolInitiation init(version); + writeDataBlock(init); - aio->start(poller); + aio->start(poller); + return; + } catch (const Rdma::Exception& e) { + QPID_LOG(error, "Rdma: Cannot create new connection (Rdma exception): " << e.what()); + } catch (const std::exception& e) { + QPID_LOG(error, "Rdma: Cannot create new connection (unknown exception): " << e.what()); + } + { + Mutex::ScopedLock l(pollingLock); + // If we're closed already then we'll get to drain() anyway + if (!polling) return; + polling = false; + } + stopped(); } void RdmaConnector::connectionError(sys::Poller::shared_ptr, Rdma::Connection::intrusive_ptr, Rdma::ErrorType) { |
