From c1ceb35c3d386e6bae5bc4dafd4e635805a97451 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Tue, 12 Oct 2010 16:04:35 +0000 Subject: Make sure that Rdma::Listener can generate no more callbacks after it receives a disconnected event for a connection id. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1021818 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/rdma/RdmaIO.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cpp/src') diff --git a/cpp/src/qpid/sys/rdma/RdmaIO.cpp b/cpp/src/qpid/sys/rdma/RdmaIO.cpp index d5f2816818..fe7062d3ea 100644 --- a/cpp/src/qpid/sys/rdma/RdmaIO.cpp +++ b/cpp/src/qpid/sys/rdma/RdmaIO.cpp @@ -564,6 +564,10 @@ namespace Rdma { ci->listen(); } + namespace { + const int64_t PoisonContext = -1; + } + void Listener::connectionEvent(Connection::intrusive_ptr ci) { ConnectionEvent e(ci->getNextEvent()); @@ -578,6 +582,11 @@ namespace Rdma { ::rdma_conn_param conn_param = e.getConnectionParam(); Rdma::Connection::intrusive_ptr id = e.getConnection(); + // Check for previous disconnection (it appears that you actually can get connection + // request events after a disconnect event in rare circumstances) + if (reinterpret_cast(id->getContext())==PoisonContext) + return; + switch (eventType) { case RDMA_CM_EVENT_CONNECT_REQUEST: { // Make sure peer has sent params we can use @@ -612,6 +621,9 @@ namespace Rdma { break; case RDMA_CM_EVENT_DISCONNECTED: disconnectedCallback(id); + // Poison the id context so that we do no more callbacks on it + id->removeContext(); + id->addContext(reinterpret_cast(PoisonContext)); break; case RDMA_CM_EVENT_CONNECT_ERROR: errorCallback(id, CONNECT_ERROR); -- cgit v1.2.1